From bafad5e34bf785da89220c6d182983a28acd8284 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Mon, 3 May 2021 04:55:49 +0100 Subject: art --- art/eventcover.psd | Bin 490028 -> 490028 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/art/eventcover.psd b/art/eventcover.psd index afbde42b..2709a8b2 100644 Binary files a/art/eventcover.psd and b/art/eventcover.psd differ -- cgit v1.2.3 From 2c58bba8f38e4164a8904d26b47d39b0165fd5b3 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Tue, 4 May 2021 03:31:50 +0100 Subject: Add "eager for more?" hidden achievement --- _RELEASE/config.json | 33 +++++++++++++++++++++++++++++++++ art/a35_eagerformore_l.png | Bin 0 -> 3828 bytes art/a35_eagerformore_u.png | Bin 0 -> 5931 bytes src/SSVOpenHexagon/Core/MenuGame.cpp | 12 ++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 art/a35_eagerformore_l.png create mode 100644 art/a35_eagerformore_u.png diff --git a/_RELEASE/config.json b/_RELEASE/config.json index bb06c50c..b8b98015 100644 --- a/_RELEASE/config.json +++ b/_RELEASE/config.json @@ -52,6 +52,39 @@ "save_local_best_replay_to_file" : true, "server_control_port" : 50506, "server_ip" : "139.162.199.162", + "server_level_whitelist" : + [ + "ohvrvanilla_vittorio_romeo_cube_1_apeirogon_m_0.35", + "ohvrvanilla_vittorio_romeo_cube_1_apeirogon_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_apeirogon_m_1.6", + "ohvrvanilla_vittorio_romeo_cube_1_commando_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_commando_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_commando_m_1.5", + "ohvrvanilla_vittorio_romeo_cube_1_euclideanpc_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_euclideanpc_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_euclideanpc_m_1.8", + "ohvrvanilla_vittorio_romeo_cube_1_flatteringshape_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_flatteringshape_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_flatteringshape_m_3", + "ohvrvanilla_vittorio_romeo_cube_1_flatteringshape_m_4", + "ohvrvanilla_vittorio_romeo_cube_1_goldenratio_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_goldenratio_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_goldenratio_m_2", + "ohvrvanilla_vittorio_romeo_cube_1_labyrinth_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_labyrinth_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_labyrinth_m_1.5", + "ohvrvanilla_vittorio_romeo_cube_1_pi_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_pi_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_pi_m_1.8", + "ohvrvanilla_vittorio_romeo_cube_1_pointless_m_0.5", + "ohvrvanilla_vittorio_romeo_cube_1_pointless_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_pointless_m_3", + "ohvrvanilla_vittorio_romeo_cube_1_pointless_m_5", + "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_0.6", + "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_1", + "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_1.8", + "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_2.2" + ], "server_local" : true, "server_port" : 50505, "server_verbose" : true, diff --git a/art/a35_eagerformore_l.png b/art/a35_eagerformore_l.png new file mode 100644 index 00000000..45410170 Binary files /dev/null and b/art/a35_eagerformore_l.png differ diff --git a/art/a35_eagerformore_u.png b/art/a35_eagerformore_u.png new file mode 100644 index 00000000..90179100 Binary files /dev/null and b/art/a35_eagerformore_u.png differ diff --git a/src/SSVOpenHexagon/Core/MenuGame.cpp b/src/SSVOpenHexagon/Core/MenuGame.cpp index c98dcd42..140ee6e5 100644 --- a/src/SSVOpenHexagon/Core/MenuGame.cpp +++ b/src/SSVOpenHexagon/Core/MenuGame.cpp @@ -313,6 +313,18 @@ MenuGame::MenuGame(Steam::steam_manager& mSteamManager, else if(lvlDrawer != nullptr) { lvlDrawer->YScrollTo += mEvent.mouseWheel.delta * 48.f; + + if(lvlDrawer->YScrollTo > 0) + { + lvlDrawer->YScrollTo = 0; + } + else if(lvlDrawer->YScrollTo < -4000) + { + // Why... + steamManager.unlock_achievement("a35_eagerformore"); + playSoundOverride("error.ogg"); + lvlDrawer->YScrollTo = 0; + } } return; -- cgit v1.2.3 From 8df4dc57d0da0bbec37a28c724d0db488edc5248 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Tue, 4 May 2021 03:32:27 +0100 Subject: Bump version to 2.0.6 --- include/SSVOpenHexagon/Global/Version.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SSVOpenHexagon/Global/Version.hpp b/include/SSVOpenHexagon/Global/Version.hpp index 60d2d1ca..c78216e7 100644 --- a/include/SSVOpenHexagon/Global/Version.hpp +++ b/include/SSVOpenHexagon/Global/Version.hpp @@ -43,7 +43,7 @@ struct GameVersion } }; -inline constexpr GameVersion GAME_VERSION{2, 0, 5}; -inline constexpr auto& GAME_VERSION_STR = "2.0.5"; +inline constexpr GameVersion GAME_VERSION{2, 0, 6}; +inline constexpr auto& GAME_VERSION_STR = "2.0.6"; } // namespace hg -- cgit v1.2.3 From dc769ef60f1805268b8e6b9bf3a039c58d34e909 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 06:37:07 +0100 Subject: refactoring --- include/SSVOpenHexagon/Components/CCustomWall.hpp | 16 ++++++++-------- include/SSVOpenHexagon/Components/CPlayer.hpp | 4 ++-- include/SSVOpenHexagon/Components/CWall.hpp | 14 +++++++------- include/SSVOpenHexagon/Utils/Casts.hpp | 2 +- include/SSVOpenHexagon/Utils/FastVertexVector.hpp | 6 +++--- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/SSVOpenHexagon/Components/CCustomWall.hpp b/include/SSVOpenHexagon/Components/CCustomWall.hpp index 0b731d9f..ebc71b92 100644 --- a/include/SSVOpenHexagon/Components/CCustomWall.hpp +++ b/include/SSVOpenHexagon/Components/CCustomWall.hpp @@ -56,7 +56,7 @@ public: wallQuads.unsafe_emplace_back(_vertexPositions[3], _vertexColors[3]); } - [[gnu::always_inline, nodiscard]] bool isOverlapping( + [[nodiscard, gnu::always_inline]] bool isOverlapping( const sf::Vector2f& point) const noexcept { return Utils::pointInPolygon(_vertexPositions, point.x, point.y); @@ -103,35 +103,35 @@ public: _flags[CWFlags::Deadly] = deadly; } - [[gnu::always_inline, nodiscard]] const sf::Vector2f& getVertexPos( + [[nodiscard, gnu::always_inline]] const sf::Vector2f& getVertexPos( const int vertexIndex) const noexcept { return _vertexPositions[vertexIndex]; } - [[gnu::always_inline, nodiscard]] const std::array& + [[nodiscard, gnu::always_inline]] const std::array& getVertexPositions() const noexcept { return _vertexPositions; } - [[gnu::always_inline, nodiscard]] const std::array& + [[nodiscard, gnu::always_inline]] const std::array& getOldVertexPositions() const noexcept { return _oldVertexPositions; } - [[gnu::always_inline, nodiscard]] bool getCanCollide() const noexcept + [[nodiscard, gnu::always_inline]] bool getCanCollide() const noexcept { return !_flags[CWFlags::NoCollision]; } - [[gnu::always_inline, nodiscard]] bool getDeadly() const noexcept + [[nodiscard, gnu::always_inline]] bool getDeadly() const noexcept { return _flags[CWFlags::Deadly]; } - [[gnu::always_inline, nodiscard]] constexpr bool + [[nodiscard, gnu::always_inline]] constexpr bool isCustomWall() const noexcept { return true; @@ -142,7 +142,7 @@ public: _killingSide = side; } - [[gnu::always_inline, nodiscard]] std::uint8_t + [[nodiscard, gnu::always_inline]] std::uint8_t getKillingSide() const noexcept { return _killingSide; diff --git a/include/SSVOpenHexagon/Components/CPlayer.hpp b/include/SSVOpenHexagon/Components/CPlayer.hpp index 234a6491..2ff20ad7 100644 --- a/include/SSVOpenHexagon/Components/CPlayer.hpp +++ b/include/SSVOpenHexagon/Components/CPlayer.hpp @@ -80,13 +80,13 @@ public: explicit CPlayer(const sf::Vector2f& pos, const float swapCooldown, const float size, const float speed, const float focusSpeed) noexcept; - [[gnu::always_inline, nodiscard]] const sf::Vector2f& + [[nodiscard, gnu::always_inline]] const sf::Vector2f& getPosition() const noexcept { return _pos; } - [[gnu::always_inline, nodiscard]] float getPlayerAngle() const noexcept + [[nodiscard, gnu::always_inline]] float getPlayerAngle() const noexcept { return _angle; } diff --git a/include/SSVOpenHexagon/Components/CWall.hpp b/include/SSVOpenHexagon/Components/CWall.hpp index a6b35b10..c4113443 100644 --- a/include/SSVOpenHexagon/Components/CWall.hpp +++ b/include/SSVOpenHexagon/Components/CWall.hpp @@ -52,41 +52,41 @@ public: void setHueMod(float hueMod) noexcept; - [[gnu::always_inline, nodiscard]] const std::array& + [[nodiscard, gnu::always_inline]] const std::array& getVertexPositions() const noexcept { return _vertexPositions; } - [[gnu::always_inline, nodiscard]] const SpeedData& getSpeed() const noexcept + [[nodiscard, gnu::always_inline]] const SpeedData& getSpeed() const noexcept { return _speed; } - [[gnu::always_inline, nodiscard]] const SpeedData& getCurve() const noexcept + [[nodiscard, gnu::always_inline]] const SpeedData& getCurve() const noexcept { return _curve; } - [[gnu::always_inline, nodiscard]] bool isOverlapping( + [[nodiscard, gnu::always_inline]] bool isOverlapping( const sf::Vector2f& point) const noexcept { return Utils::pointInPolygon(_vertexPositions, point.x, point.y); } - [[gnu::always_inline, nodiscard]] constexpr bool + [[nodiscard, gnu::always_inline]] constexpr bool isCustomWall() const noexcept { return false; } - [[gnu::always_inline, nodiscard]] std::uint8_t + [[nodiscard, gnu::always_inline]] std::uint8_t getKillingSide() const noexcept { return 0u; } - [[gnu::always_inline, nodiscard]] bool isDead() const noexcept + [[nodiscard, gnu::always_inline]] bool isDead() const noexcept { return _killed; } diff --git a/include/SSVOpenHexagon/Utils/Casts.hpp b/include/SSVOpenHexagon/Utils/Casts.hpp index 7a5c6428..a219511c 100644 --- a/include/SSVOpenHexagon/Utils/Casts.hpp +++ b/include/SSVOpenHexagon/Utils/Casts.hpp @@ -9,7 +9,7 @@ namespace hg { template -[[gnu::always_inline, nodiscard]] inline constexpr std::size_t toSizeT( +[[nodiscard, gnu::always_inline]] inline constexpr std::size_t toSizeT( const T value) noexcept { return static_cast(value); diff --git a/include/SSVOpenHexagon/Utils/FastVertexVector.hpp b/include/SSVOpenHexagon/Utils/FastVertexVector.hpp index 25d92023..1cb45651 100644 --- a/include/SSVOpenHexagon/Utils/FastVertexVector.hpp +++ b/include/SSVOpenHexagon/Utils/FastVertexVector.hpp @@ -94,7 +94,7 @@ public: _size = 0; } - [[gnu::always_inline, nodiscard]] std::size_t size() const noexcept + [[nodiscard, gnu::always_inline]] std::size_t size() const noexcept { return _size; } @@ -133,7 +133,7 @@ public: TPrimitive, mRenderStates); } - [[gnu::always_inline, nodiscard]] sf::Vertex& operator[]( + [[nodiscard, gnu::always_inline]] sf::Vertex& operator[]( const std::size_t i) noexcept { SSVOH_ASSERT(i < _size); @@ -142,7 +142,7 @@ public: return _data[i]._v; } - [[gnu::always_inline, nodiscard]] const sf::Vertex& operator[]( + [[nodiscard, gnu::always_inline]] const sf::Vertex& operator[]( const std::size_t i) const noexcept { SSVOH_ASSERT(i < _size); -- cgit v1.2.3 From e58d3bfad18c7e972bed897eaad2bbdd4290fbdb Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 06:37:55 +0100 Subject: Formatting --- build/make_debug_client_win10_msys_1_build.sh | 2 ++ build/make_debug_client_win10_msys_2_copy.sh | 4 ++++ buildlx/make_release_server_vbox_1_build.sh | 2 ++ buildlx/make_release_server_vbox_2_copy.sh | 4 ++++ buildrel/make_release_client_win10_msys_1_build.sh | 2 ++ buildrel/make_release_client_win10_msys_2_copy.sh | 4 ++++ 6 files changed, 18 insertions(+) diff --git a/build/make_debug_client_win10_msys_1_build.sh b/build/make_debug_client_win10_msys_1_build.sh index 37d60505..02f1bb39 100644 --- a/build/make_debug_client_win10_msys_1_build.sh +++ b/build/make_debug_client_win10_msys_1_build.sh @@ -7,5 +7,7 @@ echo "" echo "--------------------------------------------------------------------" echo "| BUILDING WITH NINJA |" echo "--------------------------------------------------------------------" +echo "" + ninja ninja check diff --git a/build/make_debug_client_win10_msys_2_copy.sh b/build/make_debug_client_win10_msys_2_copy.sh index ea1336ea..b63d450c 100644 --- a/build/make_debug_client_win10_msys_2_copy.sh +++ b/build/make_debug_client_win10_msys_2_copy.sh @@ -7,6 +7,8 @@ echo "" echo "--------------------------------------------------------------------" echo "| COPYING ALL EXECUTABLES TO _RELEASE FOLDER |" echo "--------------------------------------------------------------------" +echo "" + cp ./SSVOpenHexagon.exe ../_RELEASE cp ./OHWorkshopUploader.exe ../_RELEASE cp ./OHServerControl.exe ../_RELEASE @@ -16,4 +18,6 @@ echo "" echo "--------------------------------------------------------------------" echo "| COPYING LIBRARIES |" echo "--------------------------------------------------------------------" +echo "" + ./copylibs.sh diff --git a/buildlx/make_release_server_vbox_1_build.sh b/buildlx/make_release_server_vbox_1_build.sh index 37d60505..02f1bb39 100755 --- a/buildlx/make_release_server_vbox_1_build.sh +++ b/buildlx/make_release_server_vbox_1_build.sh @@ -7,5 +7,7 @@ echo "" echo "--------------------------------------------------------------------" echo "| BUILDING WITH NINJA |" echo "--------------------------------------------------------------------" +echo "" + ninja ninja check diff --git a/buildlx/make_release_server_vbox_2_copy.sh b/buildlx/make_release_server_vbox_2_copy.sh index ac885377..75e70259 100755 --- a/buildlx/make_release_server_vbox_2_copy.sh +++ b/buildlx/make_release_server_vbox_2_copy.sh @@ -7,6 +7,8 @@ echo "" echo "--------------------------------------------------------------------" echo "| COPYING TO WINDOWS DRIVE AS 'SSVOpenHexagonVbox' |" echo "--------------------------------------------------------------------" +echo "" + cp ./SSVOpenHexagon /media/sf_C_DRIVE/OHWorkspace/SSVOpenHexagon/_RELEASE/SSVOpenHexagonVbox echo "" @@ -14,5 +16,7 @@ echo "" echo "--------------------------------------------------------------------" echo "| COPYING TO VBOX DRIVE AS 'SSVOpenHexagonVbox' |" echo "--------------------------------------------------------------------" +echo "" + cp ./SSVOpenHexagon ../_RELEASE/SSVOpenHexagonVbox diff --git a/buildrel/make_release_client_win10_msys_1_build.sh b/buildrel/make_release_client_win10_msys_1_build.sh index 37d60505..02f1bb39 100644 --- a/buildrel/make_release_client_win10_msys_1_build.sh +++ b/buildrel/make_release_client_win10_msys_1_build.sh @@ -7,5 +7,7 @@ echo "" echo "--------------------------------------------------------------------" echo "| BUILDING WITH NINJA |" echo "--------------------------------------------------------------------" +echo "" + ninja ninja check diff --git a/buildrel/make_release_client_win10_msys_2_copy.sh b/buildrel/make_release_client_win10_msys_2_copy.sh index ea1336ea..b63d450c 100644 --- a/buildrel/make_release_client_win10_msys_2_copy.sh +++ b/buildrel/make_release_client_win10_msys_2_copy.sh @@ -7,6 +7,8 @@ echo "" echo "--------------------------------------------------------------------" echo "| COPYING ALL EXECUTABLES TO _RELEASE FOLDER |" echo "--------------------------------------------------------------------" +echo "" + cp ./SSVOpenHexagon.exe ../_RELEASE cp ./OHWorkshopUploader.exe ../_RELEASE cp ./OHServerControl.exe ../_RELEASE @@ -16,4 +18,6 @@ echo "" echo "--------------------------------------------------------------------" echo "| COPYING LIBRARIES |" echo "--------------------------------------------------------------------" +echo "" + ./copylibs.sh -- cgit v1.2.3 From da951cd595f844d0606b4ebd495822c23494fd47 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 07:30:27 +0100 Subject: Use LLD as the linker and update deps --- CMakeLists.txt | 38 ++++++++++----------- _RELEASE/sdkencryptedappticket64.lib | Bin 0 -> 5954 bytes build/copylibs.sh | 13 ++++++- build/make_debug_client_win10_msys_0_cmake.sh | 4 +++ buildlx/make_release_server_vbox_0_cmake.sh | 4 +++ buildrel/copylibs.sh | 13 ++++++- buildrel/make_release_client_win10_msys_0_cmake.sh | 4 +++ 7 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 _RELEASE/sdkencryptedappticket64.lib diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ec451d7..e57471ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ set(SFML_STATIC_LIBRARIES false) CPMAddPackage( NAME SFML GITHUB_REPOSITORY SFML/SFML - GIT_TAG c0b19109a97481a1edf8551e66b2a3993c7cce6d + GIT_TAG 2b79ae96d9649d26be9a3deea0862ac1ad29c19b ) set_target_properties(sfml-system PROPERTIES UNITY_BUILD ON) @@ -78,13 +78,20 @@ set(LUAJIT_DISABLE_FFI ON CACHE BOOL "" FORCE) CPMAddPackage( NAME luajit - GIT_REPOSITORY https://github.com/WohlSoft/LuaJIT - GIT_TAG 73e6a59d6add696be9b5ca3cc61ac6ae6710e5bf + GIT_REPOSITORY https://github.com/SuperV1234/LuaJIT + GIT_TAG 0591e7385dd6b3e346ef3a420561f5115da2ddf7 ) set(LUAJIT_DISABLE_FFI true) set(LUAJIT_DISABLE_FFI ON CACHE BOOL "" FORCE) +# Remove linking against libm on MinGW +if(WIN32) + file(READ "${luajit_SOURCE_DIR}/src/CMakeLists.txt" CONTENTS) + string(REGEX REPLACE "target_link_libraries\\(libluajit \\\${LIBM_LIBRARIES}\\)" "" STRIPPED1 "${CONTENTS}") + file(WRITE "${luajit_SOURCE_DIR}/src/CMakeLists.txt" "${STRIPPED1}") +endif() + # # # ----------------------------------------------------------------------------- @@ -94,7 +101,6 @@ set(LUAJIT_DISABLE_FFI ON CACHE BOOL "" FORCE) CPMAddPackage( NAME zlib GITHUB_REPOSITORY madler/zlib - VERSION 1.2.11 GIT_TAG cacf7f1d4e3d44d871b605da3b647f07d718623f ) @@ -112,8 +118,7 @@ file(WRITE "${zlib_SOURCE_DIR}/CMakeLists.txt" "${STRIPPED1}") CPMAddPackage( NAME imgui GITHUB_REPOSITORY ocornut/imgui - VERSION 1.82 - GIT_TAG d6a5cc7934b4f4f9d5effffc4f1acee151247f51 + GIT_TAG 393941ceea61e1307ffad8e3a045ab384d1299bd DOWNLOAD_ONLY YES ) @@ -137,8 +142,7 @@ endif() CPMAddPackage( NAME imgui-sfml GITHUB_REPOSITORY eliasdaler/imgui-sfml - VERSION 2.2 - GIT_TAG cec902d8c3e5e7757c150def3e46c669acf31008 + GIT_TAG 82dc2033e51b8323857c3ae1cf1f458b3a933c35 ) set_target_properties(ImGui-SFML PROPERTIES UNITY_BUILD ON) @@ -171,7 +175,7 @@ set(SODIUM_DISABLE_TESTS ON CACHE BOOL "" FORCE) CPMAddPackage( NAME boostpfr GITHUB_REPOSITORY boostorg/pfr - GIT_TAG ea4c6e85f734b0ed9f4233ba9654b877398fa948 + GIT_TAG ed82d60966436eefc8fce3ad9b87ab056a2321fd DOWNLOAD_ONLY YES ) @@ -332,9 +336,9 @@ set(SFML_LIBRARIES if(WIN32) set(PUBLIC_LIBRARIES - "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/steam_api64.dll" - "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/discord_game_sdk.dll" - "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/sdkencryptedappticket64.dll" + "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/steam_api64.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/discord_game_sdk.dll.lib" + "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/sdkencryptedappticket64.lib" sodium ) else() @@ -347,25 +351,21 @@ else() ) endif() -set(LUASRC "${luajit_SOURCE_DIR}/src") -set(LUALIB libluajit) - target_include_directories( SSVOpenHexagonLib SYSTEM PUBLIC ${SFML_SOURCE_DIR}/include PUBLIC ${PUBLIC_INCLUDE_DIRS} PUBLIC ${zlib_SOURCE_DIR} PUBLIC ${zlib_BINARY_DIR} - PUBLIC ${LUASRC} + PUBLIC ${luajit_SOURCE_DIR}/src PUBLIC ${imgui_SOURCE_DIR} PUBLIC ${boostpfr_INCLUDE_DIR} ) target_link_libraries( SSVOpenHexagonLib ${SFML_LIBRARIES} - ${LUALIB} + libluajit zlib ${PUBLIC_LIBRARIES} - "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/discord_game_sdk.dll" ImGui-SFML::ImGui-SFML ) @@ -413,7 +413,7 @@ install( # ----------------------------------------------------------------------------- if(WIN32) - set(STEAM_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/steam_api64.dll") + set(STEAM_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/steam_api64.lib") else() set(STEAM_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/_RELEASE/libsteam_api.so") endif() diff --git a/_RELEASE/sdkencryptedappticket64.lib b/_RELEASE/sdkencryptedappticket64.lib new file mode 100644 index 00000000..25216dc0 Binary files /dev/null and b/_RELEASE/sdkencryptedappticket64.lib differ diff --git a/build/copylibs.sh b/build/copylibs.sh index 8d45034b..fab3d36d 100644 --- a/build/copylibs.sh +++ b/build/copylibs.sh @@ -20,7 +20,6 @@ cp ./_deps/libsodium-cmake-build/libsodium.dll ../_RELEASE/ cp ./_deps/luajit-build/src/libluajit.dll ../_RELEASE/ cp ./_deps/zlib-build/libzlib1.dll ../_RELEASE/ - cp ./_deps/imgui-sfml-build/libImGui-SFML_d.dll ./test/ cp ./_deps/imgui-sfml-build/libImGui-SFML.dll ./test/ @@ -40,3 +39,15 @@ cp ./_deps/sfml-src/extlibs/bin/x64/openal32.dll ./test/ cp ./_deps/libsodium-cmake-build/libsodium.dll ./test/ cp ./_deps/luajit-build/src/libluajit.dll ./test/ cp ./_deps/zlib-build/libzlib1.dll ./test/ + +cp /c/msys64/mingw64/bin/libssp-0.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libssp-0.dll ./test/ + +cp /c/msys64/mingw64/bin/libstdc++-6.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libstdc++-6.dll ./test/ + +cp /c/msys64/mingw64/bin/libgcc_s_seh-1.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libgcc_s_seh-1.dll ./test/ + +cp /c/msys64/mingw64/bin/libwinpthread-1.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libwinpthread-1.dll ./test/ diff --git a/build/make_debug_client_win10_msys_0_cmake.sh b/build/make_debug_client_win10_msys_0_cmake.sh index 285c3a2a..b63dab6c 100644 --- a/build/make_debug_client_win10_msys_0_cmake.sh +++ b/build/make_debug_client_win10_msys_0_cmake.sh @@ -7,12 +7,16 @@ echo "" echo "--------------------------------------------------------------------" echo "| RUNNING CMAKE IN DEBUG MODE (NINJA) |" echo "--------------------------------------------------------------------" +echo "" + cmake .. -G"Ninja" \ -DFORCE_COLORED_OUTPUT=1 \ -DCMAKE_BUILD_TYPE=DEBUG \ -DCMAKE_C_COMPILER="gcc" \ + -DCMAKE_C_FLAGS="-fuse-ld=lld" \ -DCMAKE_CXX_COMPILER="g++" \ -DCMAKE_CXX_FLAGS="\ + -fuse-ld=lld \ -O0 -fno-omit-frame-pointer \ -Wall -Wextra -Wpedantic -Wno-braced-scalar-init -Wno-missing-field-initializers \ -D_GLIBCXX_ASSERTIONS=1 -D_FORTIFY_SOURCE=2 \ diff --git a/buildlx/make_release_server_vbox_0_cmake.sh b/buildlx/make_release_server_vbox_0_cmake.sh index 6cdd2da4..4411c374 100755 --- a/buildlx/make_release_server_vbox_0_cmake.sh +++ b/buildlx/make_release_server_vbox_0_cmake.sh @@ -7,12 +7,16 @@ echo "" echo "--------------------------------------------------------------------" echo "| RUNNING CMAKE IN RELEASE MODE (NINJA) |" echo "--------------------------------------------------------------------" +echo "" + cmake .. -G"Ninja" \ -DFORCE_COLORED_OUTPUT=1 \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_C_COMPILER="gcc" \ + -DCMAKE_C_FLAGS="-fuse-ld=lld" \ -DCMAKE_CXX_COMPILER="g++" \ -DCMAKE_CXX_FLAGS="\ + -fuse-ld=lld \ -Wall -Wextra -Wpedantic -Wno-braced-scalar-init \ -Wno-pragmas -Wno-missing-field-initializers \ -O3 -DNDEBUG\ diff --git a/buildrel/copylibs.sh b/buildrel/copylibs.sh index 8d45034b..fab3d36d 100644 --- a/buildrel/copylibs.sh +++ b/buildrel/copylibs.sh @@ -20,7 +20,6 @@ cp ./_deps/libsodium-cmake-build/libsodium.dll ../_RELEASE/ cp ./_deps/luajit-build/src/libluajit.dll ../_RELEASE/ cp ./_deps/zlib-build/libzlib1.dll ../_RELEASE/ - cp ./_deps/imgui-sfml-build/libImGui-SFML_d.dll ./test/ cp ./_deps/imgui-sfml-build/libImGui-SFML.dll ./test/ @@ -40,3 +39,15 @@ cp ./_deps/sfml-src/extlibs/bin/x64/openal32.dll ./test/ cp ./_deps/libsodium-cmake-build/libsodium.dll ./test/ cp ./_deps/luajit-build/src/libluajit.dll ./test/ cp ./_deps/zlib-build/libzlib1.dll ./test/ + +cp /c/msys64/mingw64/bin/libssp-0.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libssp-0.dll ./test/ + +cp /c/msys64/mingw64/bin/libstdc++-6.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libstdc++-6.dll ./test/ + +cp /c/msys64/mingw64/bin/libgcc_s_seh-1.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libgcc_s_seh-1.dll ./test/ + +cp /c/msys64/mingw64/bin/libwinpthread-1.dll ../_RELEASE/ +cp /c/msys64/mingw64/bin/libwinpthread-1.dll ./test/ diff --git a/buildrel/make_release_client_win10_msys_0_cmake.sh b/buildrel/make_release_client_win10_msys_0_cmake.sh index 56d2fb67..455cfcd1 100644 --- a/buildrel/make_release_client_win10_msys_0_cmake.sh +++ b/buildrel/make_release_client_win10_msys_0_cmake.sh @@ -7,12 +7,16 @@ echo "" echo "--------------------------------------------------------------------" echo "| RUNNING CMAKE IN RELEASE MODE (NINJA) |" echo "--------------------------------------------------------------------" +echo "" + cmake .. -G"Ninja" \ -DFORCE_COLORED_OUTPUT=1 \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_C_COMPILER="gcc" \ + -DCMAKE_C_FLAGS="-fuse-ld=lld" \ -DCMAKE_CXX_COMPILER="g++" \ -DCMAKE_CXX_FLAGS="\ + -fuse-ld=lld \ -Wall -Wextra -Wpedantic -Wno-braced-scalar-init \ -Wno-pragmas -Wno-missing-field-initializers \ -O3 -DNDEBUG\ -- cgit v1.2.3 From d94411f28b21a86cda2976dddc33324142f69d04 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 07:30:40 +0100 Subject: Fix warnings on clang --- src/SSVOpenHexagon/Core/Replay.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/SSVOpenHexagon/Core/Replay.cpp b/src/SSVOpenHexagon/Core/Replay.cpp index 809ba475..b8f2b6cd 100644 --- a/src/SSVOpenHexagon/Core/Replay.cpp +++ b/src/SSVOpenHexagon/Core/Replay.cpp @@ -148,19 +148,20 @@ void replay_data::record_input(const bool left, const bool right, _inputs.resize(n_inputs); +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif for(std::size_t i = 0; i < n_inputs; ++i) -#pragma GCC diagnostic pop { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" std::uint8_t ib_byte; SSVOH_TRY(read(ib_byte)); -#pragma GCC diagnostic pop _inputs[i] = input_bitset{static_cast(ib_byte)}; } +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif return result; } @@ -279,8 +280,10 @@ void replay_player::reset() noexcept s.resize(s_size); +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif for(std::uint32_t i = 0; i < s_size; ++i) { char c; @@ -288,7 +291,9 @@ void replay_player::reset() noexcept s[i] = c; } +#if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic pop +#endif return result; }; -- cgit v1.2.3 From 75edfa554bdd3efbf86ca5580538ec3d1a902fcd Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 07:30:55 +0100 Subject: Cleanup CMake stuff --- test/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b08c622b..3be7ad93 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,10 +23,9 @@ foreach(_t IN LISTS vrm_cmake_out) target_link_libraries(${_t} ${SFML_LIBRARIES} - ${LUALIB} + libluajit zlib ${PUBLIC_LIBRARIES} - "${CMAKE_CURRENT_SOURCE_DIR}/../_RELEASE/discord_game_sdk.dll" SSVOpenHexagonLib SSVOpenHexagonLibC ) -- cgit v1.2.3 From a39f6589f2f1058a60f51d65c6cb562c908aa7af Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 20:44:18 +0100 Subject: Minor compilation speed improvements --- include/SSVOpenHexagon/Core/MenuGame.hpp | 3 +- include/SSVOpenHexagon/Core/Steam.hpp | 5 +- include/SSVOpenHexagon/Global/AssetStorage.hpp | 5 +- include/SSVOpenHexagon/Global/Assets.hpp | 5 +- include/SSVOpenHexagon/Global/Audio.hpp | 5 +- include/SSVOpenHexagon/Utils/ArgExtractor.hpp | 15 +- include/SSVOpenHexagon/Utils/FastVertexVector.hpp | 11 +- include/SSVOpenHexagon/Utils/LuaMetadataProxy.hpp | 61 ++++--- include/SSVOpenHexagon/Utils/LuaWrapper.hpp | 213 +++++++++++----------- include/SSVOpenHexagon/Utils/UniquePtr.hpp | 95 ++++++++++ include/SSVOpenHexagon/Utils/UniquePtrArray.hpp | 108 +++++++++++ src/SSVOpenHexagon/Core/Audio.cpp | 5 +- src/SSVOpenHexagon/Core/MenuGame.cpp | 3 +- src/SSVOpenHexagon/Core/Steam.cpp | 4 +- src/SSVOpenHexagon/Global/AssetStorage.cpp | 5 +- src/SSVOpenHexagon/Global/Assets.cpp | 19 +- 16 files changed, 385 insertions(+), 177 deletions(-) create mode 100644 include/SSVOpenHexagon/Utils/UniquePtr.hpp create mode 100644 include/SSVOpenHexagon/Utils/UniquePtrArray.hpp diff --git a/include/SSVOpenHexagon/Core/MenuGame.hpp b/include/SSVOpenHexagon/Core/MenuGame.hpp index 0af12c82..697edef1 100644 --- a/include/SSVOpenHexagon/Core/MenuGame.hpp +++ b/include/SSVOpenHexagon/Core/MenuGame.hpp @@ -12,6 +12,7 @@ #include "SSVOpenHexagon/Utils/FastVertexVector.hpp" #include "SSVOpenHexagon/Utils/LuaWrapper.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" #include @@ -109,7 +110,7 @@ private: ssvs::GameWindow& window; HexagonClient& hexagonClient; HexagonDialogBox dialogBox; - std::unique_ptr leaderboardCache; + Utils::UniquePtr leaderboardCache; Lua::LuaContext lua; std::vector execScriptPackPathContext; diff --git a/include/SSVOpenHexagon/Core/Steam.hpp b/include/SSVOpenHexagon/Core/Steam.hpp index edf527dd..a1a48415 100644 --- a/include/SSVOpenHexagon/Core/Steam.hpp +++ b/include/SSVOpenHexagon/Core/Steam.hpp @@ -4,9 +4,10 @@ #pragma once +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" + #include #include -#include #include #include #include @@ -18,7 +19,7 @@ class steam_manager private: class steam_manager_impl; - std::unique_ptr _impl; + Utils::UniquePtr _impl; [[nodiscard]] const steam_manager_impl& impl() const noexcept; [[nodiscard]] steam_manager_impl& impl() noexcept; diff --git a/include/SSVOpenHexagon/Global/AssetStorage.hpp b/include/SSVOpenHexagon/Global/AssetStorage.hpp index 5444f354..915ae09a 100644 --- a/include/SSVOpenHexagon/Global/AssetStorage.hpp +++ b/include/SSVOpenHexagon/Global/AssetStorage.hpp @@ -4,8 +4,9 @@ #pragma once +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" + #include -#include namespace sf { @@ -22,7 +23,7 @@ class AssetStorage private: class AssetStorageImpl; - std::unique_ptr _impl; + Utils::UniquePtr _impl; [[nodiscard]] const AssetStorageImpl& impl() const noexcept; [[nodiscard]] AssetStorageImpl& impl() noexcept; diff --git a/include/SSVOpenHexagon/Global/Assets.hpp b/include/SSVOpenHexagon/Global/Assets.hpp index 80e1a1ab..49689224 100644 --- a/include/SSVOpenHexagon/Global/Assets.hpp +++ b/include/SSVOpenHexagon/Global/Assets.hpp @@ -11,9 +11,10 @@ #include "SSVOpenHexagon/Data/LoadInfo.hpp" #include "SSVOpenHexagon/Data/PackInfo.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" + #include #include -#include #include #include #include @@ -46,7 +47,7 @@ private: bool levelsOnly{false}; - std::unique_ptr assetStorage; + Utils::UniquePtr assetStorage; std::unordered_map levelDatas; std::unordered_map> diff --git a/include/SSVOpenHexagon/Global/Audio.hpp b/include/SSVOpenHexagon/Global/Audio.hpp index a88d8998..fee871fc 100644 --- a/include/SSVOpenHexagon/Global/Audio.hpp +++ b/include/SSVOpenHexagon/Global/Audio.hpp @@ -4,8 +4,9 @@ #pragma once +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" + #include -#include #include namespace sf { @@ -26,7 +27,7 @@ public: private: class AudioImpl; - std::unique_ptr _impl; + Utils::UniquePtr _impl; [[nodiscard]] const AudioImpl& impl() const noexcept; [[nodiscard]] AudioImpl& impl() noexcept; diff --git a/include/SSVOpenHexagon/Utils/ArgExtractor.hpp b/include/SSVOpenHexagon/Utils/ArgExtractor.hpp index 43257d1e..d28d7c88 100644 --- a/include/SSVOpenHexagon/Utils/ArgExtractor.hpp +++ b/include/SSVOpenHexagon/Utils/ArgExtractor.hpp @@ -18,22 +18,19 @@ struct ArgExtractor using Return = R; using Function = F; - inline static constexpr std::size_t numArgs = sizeof...(Args); + enum + { + numArgs = sizeof...(Args) + }; template using NthArg = std::tuple_element_t>; }; template -struct ArgExtractor +struct ArgExtractor : ArgExtractor { - using Return = R; - using Function = F; - - inline static constexpr std::size_t numArgs = sizeof...(Args); - - template - using NthArg = std::tuple_element_t>; + using ArgExtractor::NthArg; }; } // namespace hg::Utils diff --git a/include/SSVOpenHexagon/Utils/FastVertexVector.hpp b/include/SSVOpenHexagon/Utils/FastVertexVector.hpp index 1cb45651..f53874ef 100644 --- a/include/SSVOpenHexagon/Utils/FastVertexVector.hpp +++ b/include/SSVOpenHexagon/Utils/FastVertexVector.hpp @@ -6,6 +6,8 @@ #include "SSVOpenHexagon/Global/Assert.hpp" +#include "SSVOpenHexagon/Utils/UniquePtrArray.hpp" + #include #include #include @@ -16,7 +18,6 @@ #include #include -#include namespace hg::Utils { @@ -37,7 +38,7 @@ private: static_assert(sizeof(VertexUnion) == sizeof(sf::Vertex)); static_assert(alignof(VertexUnion) == alignof(sf::Vertex)); - std::unique_ptr _data{nullptr}; + Utils::UniquePtrArray _data{nullptr}; std::size_t _size{}; std::size_t _capacity{}; @@ -54,7 +55,7 @@ public: return; } - auto new_data = std::make_unique(n); + auto new_data = Utils::makeUniqueArray(n); if(SSVU_UNLIKELY(_data != nullptr)) { @@ -129,8 +130,8 @@ public: } // UB: - mRenderTarget.draw(reinterpret_cast(_data.get()), _size, - TPrimitive, mRenderStates); + mRenderTarget.draw(reinterpret_cast(_data.get()), + _size, TPrimitive, mRenderStates); } [[nodiscard, gnu::always_inline]] sf::Vertex& operator[]( diff --git a/include/SSVOpenHexagon/Utils/LuaMetadataProxy.hpp b/include/SSVOpenHexagon/Utils/LuaMetadataProxy.hpp index f8a4b0ee..792541ae 100644 --- a/include/SSVOpenHexagon/Utils/LuaMetadataProxy.hpp +++ b/include/SSVOpenHexagon/Utils/LuaMetadataProxy.hpp @@ -34,55 +34,56 @@ private: template [[nodiscard]] static std::string typeToStr(TypeWrapper>); - template - static void addTypeToStr(std::vector& types) - { - types.emplace_back(typeToStr(TypeWrapper>{})); - } - template [[nodiscard]] static std::string makeArgsString(LuaMetadataProxy* self) { using AE = Utils::ArgExtractor; - std::vector types; - - [&](std::index_sequence) - { - (addTypeToStr>(types), ...); - } - (std::make_index_sequence{}); - - if(types.empty()) + if constexpr(AE::numArgs == 0) { return ""; } + else if constexpr(AE::numArgs == 1) + { + std::string res; - std::string res = types.at(0) + " " + self->argNames.at(0); + res += typeToStr( + TypeWrapper>>{}); + + res += ' '; + res += self->argNames.at(0); - if(types.size() == 1) - { return res; } - - for(std::size_t i = 1; i < types.size(); ++i) + else { - res += ", "; - res += types.at(i); - res += " "; - res += self->argNames.at(i); - } + std::string res; + + [&](std::index_sequence) + { + (( // + res += typeToStr(TypeWrapper< + std::decay_t>>{}), // + res += ' ', // + res += self->argNames.at(Is), // + res += ", "), + ...); + } + (std::make_index_sequence{}); + + res.pop_back(); + res.pop_back(); - return res; + return res; + } } [[nodiscard]] std::string resolveArgNames(const std::string& docs); - template + template [[nodiscard]] static std::string makeErasedRet(LuaMetadataProxy*) { - using AE = Utils::ArgExtractor; - return typeToStr(TypeWrapper>{}); + return typeToStr(TypeWrapper>{}); } public: @@ -91,7 +92,7 @@ public: TypeWrapper, LuaMetadata& mLuaMetadata, const std::string& mName) : luaMetadata{mLuaMetadata}, name{mName}, - erasedRet{&makeErasedRet}, + erasedRet{&makeErasedRet::Return>}, erasedArgs{&makeArgsString} {} diff --git a/include/SSVOpenHexagon/Utils/LuaWrapper.hpp b/include/SSVOpenHexagon/Utils/LuaWrapper.hpp index 361cb16a..0d11bbfa 100644 --- a/include/SSVOpenHexagon/Utils/LuaWrapper.hpp +++ b/include/SSVOpenHexagon/Utils/LuaWrapper.hpp @@ -72,7 +72,10 @@ struct FnTupleWrapper template struct FnTupleWrapper { - static constexpr int count{sizeof...(TArgs)}; + enum + { + count = sizeof...(TArgs) + }; using ParamsType = std::tuple; template @@ -87,7 +90,10 @@ struct FnTupleWrapper template struct FnTupleWrapper { - static constexpr int count{sizeof...(TArgs)}; + enum + { + count = sizeof...(TArgs) + }; using ParamsType = std::tuple; template @@ -884,8 +890,8 @@ public: template void insert(Key&& k, Value&& v, Args&&... args) { - typedef typename ToPushableType>::type RKey; - typedef typename ToPushableType>::type RValue; + using RKey = typename ToPushableType>::type; + using RValue = typename ToPushableType>::type; _elements.emplace_back(new Element( std::forward(k), std::forward(v))); @@ -1070,110 +1076,111 @@ private: return 1; } + template + static auto callbackCall(lua_State* lua) + { + // this function is called when the lua script tries to call our + // custom data type + // what we do is we simply call the function + SSVOH_ASSERT(lua_gettop(lua) >= 1); + SSVOH_ASSERT(lua_isuserdata(lua, 1)); + + auto function = (FunctionPushType*)lua_touserdata(lua, 1); + + SSVOH_ASSERT(function); + return (*function)(lua); + } + + template + static int callbackGarbage(lua_State* lua) + { + // this one is called when lua's garbage collector no longer + // needs our custom data type + // we call std::function's destructor + SSVOH_ASSERT(lua_gettop(lua) == 1); + + auto function = (FunctionPushType*)lua_touserdata(lua, 1); + + SSVOH_ASSERT(function); + function->~FunctionPushType(); + + return 0; + } + + template + struct FunctionToPush + { + LuaContext* _ctx; + F _fn; + + auto operator()(lua_State* state) const + { + SSVOH_ASSERT(_ctx->_state == state); + + // FnTupleWrapper is a specialized template + // structure which defines + // "ParamsType", "ReturnType" and "call" + // the first two correspond to the params list and return + // type as tuples + // and "call" is a static function which will call a + // function + // of this type using parameters passed as a tuple + using FnType = typename RemoveMemberPtr::Type; + using TupledFunction = FnTupleWrapper; + + // checking if number of parameters is correct + if(lua_gettop(state) < TupledFunction::count) + { + // if not, using lua_error to return an error + luaL_where(state, 1); + lua_pushstring(state, "this function requires at least "); + lua_pushnumber(state, TupledFunction::count); + lua_pushstring(state, " parameter(s)"); + lua_concat(state, 4); + return lua_error(state); // lua_error throws an + // exception when compiling as + // C++ + } + + // pushing the result on the stack and returning number of + // pushed elements + return _ctx->_push( + // calling the function, result should be a tuple + TupledFunction::call(_fn, + + // reading parameters from the stack + _ctx->_read(-TupledFunction::count, + static_cast( + nullptr)))); + } + }; + // when you call _push with a functor, this definition should be used // (thanks to SFINAE) // it will determine the function category using its () operator, then // generate a callable user data and push it - template ::operator())> + template , + typename Op = decltype(&DecayT::operator())> int _push(T&& fn, Op = nullptr) { - // the () operator has type "R(T::*)(Args)", this typedef converts - // it to "R(Args)" - using FnType = typename RemoveMemberPtr::Type; - // when the lua script calls the thing we will push on the stack, we // want "fn" to be executed // if we used lua's cfunctions system, we could not detect when the // function is no longer in use, which could cause problems // so we use userdata instead - // we will create a userdata which contains a copy of a lambda - // function [](lua_State*) -> int - // but first we have to create it - auto functionToPush( - [this, fn = std::forward(fn)](lua_State* state) - { - // note that I'm using "" because of g++, - // I don't know if it is required by standards or if it is a - // bug - SSVOH_ASSERT(_state == state); - - // FnTupleWrapper is a specialized template - // structure which defines - // "ParamsType", "ReturnType" and "call" - // the first two correspond to the params list and return - // type as tuples - // and "call" is a static function which will call a - // function - // of this type using parameters passed as a tuple - using TupledFunction = FnTupleWrapper; - - // checking if number of parameters is correct - constexpr int paramsCount = TupledFunction::count; - if(lua_gettop(state) < paramsCount) - { - // if not, using lua_error to return an error - luaL_where(state, 1); - lua_pushstring(state, "this function requires at least "); - lua_pushnumber(state, paramsCount); - lua_pushstring(state, " parameter(s)"); - lua_concat(state, 4); - return lua_error(state); // lua_error throws an - // exception when compiling as - // C++ - } - - // pushing the result on the stack and returning number of - // pushed elements - return _push( - // calling the function, result should be a tuple - TupledFunction::call(fn, - - // reading parameters from the stack - _read(-paramsCount, - static_cast( - nullptr)))); - }); - // typedefing the type of data we will push - using FunctionPushType = decltype(functionToPush); - - auto callbackCall = [](lua_State* lua) - { - // this function is called when the lua script tries to call our - // custom data type - // what we do is we simply call the function - SSVOH_ASSERT(lua_gettop(lua) >= 1); - SSVOH_ASSERT(lua_isuserdata(lua, 1)); - - auto function = (FunctionPushType*)lua_touserdata(lua, 1); - - SSVOH_ASSERT(function); - return (*function)(lua); - }; - - auto callbackGarbage = [](lua_State* lua) - { - // this one is called when lua's garbage collector no longer - // needs our custom data type - // we call std::function's destructor - SSVOH_ASSERT(lua_gettop(lua) == 1); - - auto function = (FunctionPushType*)lua_touserdata(lua, 1); - - SSVOH_ASSERT(function); - function->~FunctionPushType(); - return 0; - }; + using FunctionPushType = FunctionToPush; // creating the object // lua_newuserdata allocates memory in the internals of the lua // library and returns it so we can fill it // and that's what we do with placement-new - auto const functionLocation = (FunctionPushType*)lua_newuserdata( + auto* const functionLocation = (FunctionPushType*)lua_newuserdata( _state, sizeof(FunctionPushType)); - new(functionLocation) FunctionPushType(std::move(functionToPush)); + new(functionLocation) + FunctionPushType{._ctx = this, ._fn = std::forward(fn)}; // creating the metatable (over the object on the stack) // lua_settable pops the key and value we just pushed, so stack @@ -1181,14 +1188,17 @@ private: // all that remains on the stack after these function calls is the // metatable lua_newtable(_state); + lua_pushstring(_state, "__call"); - lua_pushcfunction(_state, callbackCall); + lua_pushcfunction(_state, &callbackCall); lua_settable(_state, -3); + lua_pushstring(_state, "_typeid"); lua_pushlightuserdata(_state, const_cast(&typeid(T))); lua_settable(_state, -3); + lua_pushstring(_state, "__gc"); - lua_pushcfunction(_state, callbackGarbage); + lua_pushcfunction(_state, &callbackGarbage); lua_settable(_state, -3); // at this point, the stack contains the object at offset -2 and the @@ -1230,8 +1240,7 @@ private: { SSVOH_ASSERT(lua_gettop(lua) == 1); - std::shared_ptr* ptr = - (std::shared_ptr*)lua_touserdata(lua, 1); + auto* ptr = (std::shared_ptr*)lua_touserdata(lua, 1); SSVOH_ASSERT(ptr && *ptr); ptr->~shared_ptr(); @@ -1515,24 +1524,6 @@ return table;*/ } }; -template -struct IsFunctor -{ - using one = char; - using two = long; - - template - static one test(decltype(&C::operator())); - - template - static two test(...); - - enum - { - value = sizeof(test(0)) == sizeof(char) - }; -}; - template struct LuaContext::ToPushableType { @@ -1607,7 +1598,7 @@ struct LuaContext::ToPushableType }; template -struct LuaContext::ToPushableType::value>> +struct LuaContext::ToPushableType { using type = T; }; diff --git a/include/SSVOpenHexagon/Utils/UniquePtr.hpp b/include/SSVOpenHexagon/Utils/UniquePtr.hpp new file mode 100644 index 00000000..7f474134 --- /dev/null +++ b/include/SSVOpenHexagon/Utils/UniquePtr.hpp @@ -0,0 +1,95 @@ +// Copyright (c) 2013-2020 Vittorio Romeo +// License: Academic Free License ("AFL") v. 3.0 +// AFL License page: https://opensource.org/licenses/AFL-3.0 + +#pragma once + +#include "SSVOpenHexagon/Global/Assert.hpp" + +namespace hg::Utils { + +template +class UniquePtr +{ +private: + T* _ptr; + +public: + [[nodiscard, gnu::always_inline]] explicit UniquePtr() noexcept + : _ptr{nullptr} + {} + + [[nodiscard, gnu::always_inline]] explicit UniquePtr(T* ptr) noexcept + : _ptr{ptr} + {} + + [[gnu::always_inline]] ~UniquePtr() noexcept + { + delete _ptr; + } + + UniquePtr(const UniquePtr&) = delete; + UniquePtr& operator=(const UniquePtr&) = delete; + + [[nodiscard, gnu::always_inline]] UniquePtr(UniquePtr&& rhs) noexcept + : _ptr{rhs._ptr} + { + rhs._ptr = nullptr; + } + + [[nodiscard, gnu::always_inline]] T& operator*() noexcept + { + SSVOH_ASSERT(_ptr != nullptr); + return *_ptr; + } + + [[nodiscard, gnu::always_inline]] const T& operator*() const noexcept + { + SSVOH_ASSERT(_ptr != nullptr); + return *_ptr; + } + + [[nodiscard, gnu::always_inline]] T* operator->() noexcept + { + SSVOH_ASSERT(_ptr != nullptr); + return _ptr; + } + + [[nodiscard, gnu::always_inline]] const T* operator->() const noexcept + { + SSVOH_ASSERT(_ptr != nullptr); + return _ptr; + } + + [[nodiscard, gnu::always_inline]] bool operator==( + const T* ptr) const noexcept + { + return _ptr == ptr; + } + + [[nodiscard, gnu::always_inline]] bool operator!=( + const T* ptr) const noexcept + { + return _ptr != ptr; + } + + [[nodiscard, gnu::always_inline]] bool operator==( + decltype(nullptr)) const noexcept + { + return _ptr == nullptr; + } + + [[nodiscard, gnu::always_inline]] bool operator!=( + decltype(nullptr)) const noexcept + { + return _ptr != nullptr; + } +}; + +template +[[nodiscard, gnu::always_inline]] inline UniquePtr makeUnique(Ts&&... xs) +{ + return UniquePtr{new T{static_cast(xs)...}}; +} + +} // namespace hg::Utils diff --git a/include/SSVOpenHexagon/Utils/UniquePtrArray.hpp b/include/SSVOpenHexagon/Utils/UniquePtrArray.hpp new file mode 100644 index 00000000..3b2da868 --- /dev/null +++ b/include/SSVOpenHexagon/Utils/UniquePtrArray.hpp @@ -0,0 +1,108 @@ +// Copyright (c) 2013-2020 Vittorio Romeo +// License: Academic Free License ("AFL") v. 3.0 +// AFL License page: https://opensource.org/licenses/AFL-3.0 + +#pragma once + +#include "SSVOpenHexagon/Global/Assert.hpp" + +namespace hg::Utils { + +template +class UniquePtrArray +{ +private: + using SizeT = decltype(sizeof(int)); + + T* _ptr; + +public: + [[nodiscard, gnu::always_inline]] explicit UniquePtrArray() noexcept + : _ptr{nullptr} + {} + + [[nodiscard, gnu::always_inline]] explicit UniquePtrArray(T* ptr) noexcept + : _ptr{ptr} + {} + + [[gnu::always_inline]] ~UniquePtrArray() noexcept + { + delete[] _ptr; + } + + UniquePtrArray(const UniquePtrArray&) = delete; + UniquePtrArray& operator=(const UniquePtrArray&) = delete; + + [[nodiscard, gnu::always_inline]] UniquePtrArray( + UniquePtrArray&& rhs) noexcept + : _ptr{rhs._ptr} + { + rhs._ptr = nullptr; + } + + UniquePtrArray& operator=(UniquePtrArray&& rhs) noexcept + { + delete[] _ptr; + + _ptr = rhs._ptr; + rhs._ptr = nullptr; + + return *this; + } + + [[nodiscard, gnu::always_inline]] T* get() noexcept + { + return _ptr; + } + + [[nodiscard, gnu::always_inline]] const T* get() const noexcept + { + return _ptr; + } + + [[nodiscard, gnu::always_inline]] T& operator[](const SizeT i) noexcept + { + SSVOH_ASSERT(_ptr != nullptr); + return _ptr[i]; + } + + [[nodiscard, gnu::always_inline]] const T& operator[]( + const SizeT i) const noexcept + { + SSVOH_ASSERT(_ptr != nullptr); + return _ptr[i]; + } + + [[nodiscard, gnu::always_inline]] bool operator==( + const T* ptr) const noexcept + { + return _ptr == ptr; + } + + [[nodiscard, gnu::always_inline]] bool operator!=( + const T* ptr) const noexcept + { + return _ptr != ptr; + } + + [[nodiscard, gnu::always_inline]] bool operator==( + decltype(nullptr)) const noexcept + { + return _ptr == nullptr; + } + + [[nodiscard, gnu::always_inline]] bool operator!=( + decltype(nullptr)) const noexcept + { + return _ptr != nullptr; + } +}; + +template +[[nodiscard, gnu::always_inline]] inline UniquePtrArray makeUniqueArray( + decltype(sizeof(int)) capacity) +{ + return UniquePtrArray{new T[capacity]}; +} + +} // namespace hg::Utils diff --git a/src/SSVOpenHexagon/Core/Audio.cpp b/src/SSVOpenHexagon/Core/Audio.cpp index 23c97243..aefa5d7b 100644 --- a/src/SSVOpenHexagon/Core/Audio.cpp +++ b/src/SSVOpenHexagon/Core/Audio.cpp @@ -5,7 +5,9 @@ #include "SSVOpenHexagon/Global/Audio.hpp" #include "SSVOpenHexagon/Global/Assert.hpp" + #include "SSVOpenHexagon/Utils/Concat.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" #include @@ -14,7 +16,6 @@ #include #include -#include #include #include @@ -190,7 +191,7 @@ public: Audio::Audio(const SoundBufferGetter& soundBufferGetter, const MusicPathGetter& musicPathGetter) - : _impl{std::make_unique(soundBufferGetter, musicPathGetter)} + : _impl{Utils::makeUnique(soundBufferGetter, musicPathGetter)} {} Audio::~Audio() = default; diff --git a/src/SSVOpenHexagon/Core/MenuGame.cpp b/src/SSVOpenHexagon/Core/MenuGame.cpp index 140ee6e5..491b5161 100644 --- a/src/SSVOpenHexagon/Core/MenuGame.cpp +++ b/src/SSVOpenHexagon/Core/MenuGame.cpp @@ -42,6 +42,7 @@ #include "SSVOpenHexagon/Utils/Match.hpp" #include "SSVOpenHexagon/Utils/ScopeGuard.hpp" #include "SSVOpenHexagon/Utils/String.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" #include "SSVOpenHexagon/Utils/Utils.hpp" #include @@ -155,7 +156,7 @@ MenuGame::MenuGame(Steam::steam_manager& mSteamManager, window(mGameWindow), hexagonClient{mHexagonClient}, dialogBox(imagine, mGameWindow), - leaderboardCache{std::make_unique()}, + leaderboardCache{Utils::makeUnique()}, lua{}, execScriptPackPathContext{}, currentPack{nullptr}, diff --git a/src/SSVOpenHexagon/Core/Steam.cpp b/src/SSVOpenHexagon/Core/Steam.cpp index 551d14aa..c7470c8c 100644 --- a/src/SSVOpenHexagon/Core/Steam.cpp +++ b/src/SSVOpenHexagon/Core/Steam.cpp @@ -6,6 +6,8 @@ #include "SSVOpenHexagon/Global/Assert.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" + #include #include // Steam API needs this. @@ -833,7 +835,7 @@ steam_manager::impl() const noexcept return *_impl; } -steam_manager::steam_manager() : _impl{std::make_unique()} +steam_manager::steam_manager() : _impl{Utils::makeUnique()} {} steam_manager::~steam_manager() = default; diff --git a/src/SSVOpenHexagon/Global/AssetStorage.cpp b/src/SSVOpenHexagon/Global/AssetStorage.cpp index 22fb2c74..ce126252 100644 --- a/src/SSVOpenHexagon/Global/AssetStorage.cpp +++ b/src/SSVOpenHexagon/Global/AssetStorage.cpp @@ -5,7 +5,9 @@ #include "SSVOpenHexagon/Global/AssetStorage.hpp" #include "SSVOpenHexagon/Global/Assert.hpp" + #include "SSVOpenHexagon/Utils/Concat.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" #include #include @@ -14,7 +16,6 @@ #include #include -#include #include namespace hg { @@ -114,7 +115,7 @@ AssetStorage::impl() const noexcept return *_impl; } -AssetStorage::AssetStorage() : _impl{std::make_unique()} +AssetStorage::AssetStorage() : _impl{Utils::makeUnique()} {} AssetStorage::~AssetStorage() = default; diff --git a/src/SSVOpenHexagon/Global/Assets.cpp b/src/SSVOpenHexagon/Global/Assets.cpp index 281a8182..18d164b9 100644 --- a/src/SSVOpenHexagon/Global/Assets.cpp +++ b/src/SSVOpenHexagon/Global/Assets.cpp @@ -4,17 +4,22 @@ #include "SSVOpenHexagon/Global/Assets.hpp" +#include "SSVOpenHexagon/Core/Steam.hpp" + +#include "SSVOpenHexagon/Data/MusicData.hpp" + #include "SSVOpenHexagon/Global/Assert.hpp" #include "SSVOpenHexagon/Global/AssetStorage.hpp" +#include "SSVOpenHexagon/Global/UtilsJson.hpp" #include "SSVOpenHexagon/Global/Version.hpp" -#include "SSVOpenHexagon/Utils/LoadFromJson.hpp" -#include "SSVOpenHexagon/Utils/Concat.hpp" + +#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp" + #include "SSVOpenHexagon/Utils/BuildPackId.hpp" +#include "SSVOpenHexagon/Utils/Concat.hpp" #include "SSVOpenHexagon/Utils/EraseIf.hpp" -#include "SSVOpenHexagon/Data/MusicData.hpp" -#include "SSVOpenHexagon/SSVUtilsJson/SSVUtilsJson.hpp" -#include "SSVOpenHexagon/Global/UtilsJson.hpp" -#include "SSVOpenHexagon/Core/Steam.hpp" +#include "SSVOpenHexagon/Utils/LoadFromJson.hpp" +#include "SSVOpenHexagon/Utils/UniquePtr.hpp" #include @@ -115,7 +120,7 @@ HGAssets::HGAssets( Steam::steam_manager* mSteamManager, bool mHeadless, bool mLevelsOnly) : steamManager{mSteamManager}, levelsOnly{mLevelsOnly}, - assetStorage{std::make_unique()} + assetStorage{Utils::makeUnique()} { using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point; -- cgit v1.2.3 From a3112838cd94d9cf7457b1b47ead6ed6aad139c9 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 20:44:25 +0100 Subject: Main cleanup --- src/SSVOpenHexagon/Core/main.cpp | 50 +++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/src/SSVOpenHexagon/Core/main.cpp b/src/SSVOpenHexagon/Core/main.cpp index ca9bdf64..03d1b979 100644 --- a/src/SSVOpenHexagon/Core/main.cpp +++ b/src/SSVOpenHexagon/Core/main.cpp @@ -156,6 +156,36 @@ std::optional getFirstCompressedReplayFilenameFromArgs( } // namespace +// +// +// ---------------------------------------------------------------------------- +// Print lua docs entrypoint +// ---------------------------------------------------------------------------- + +[[nodiscard]] int mainPrintLuaDocs() +{ + hg::HGAssets assets{ + nullptr, /* steamManager */ // + true /* headless */ // + }; + + hg::HexagonGame hg{ + nullptr /* steamManager */, // + nullptr /* discordManager */, // + assets, // + nullptr /* audio */, // + nullptr /* window */, // + nullptr /* client */ // + }; + + std::cout << "\n\n\n\n\n"; + hg.initLuaAndPrintDocs(); + std::cout << "\n\n\n\n\n"; + + ssvu::lo("::mainPrintLuaDocs") << "Finished\n"; + return 0; +} + // // // ---------------------------------------------------------------------------- @@ -202,7 +232,7 @@ std::optional getFirstCompressedReplayFilenameFromArgs( // Client main entrypoint // ---------------------------------------------------------------------------- -[[nodiscard]] int mainClient(const bool headless, const bool printLuaDocs, +[[nodiscard]] int mainClient(const bool headless, const std::vector& args, const std::optional& cliLevelName, const std::optional& cliLevelPack) @@ -359,12 +389,6 @@ std::optional getFirstCompressedReplayFilenameFromArgs( &hc // }; - if(printLuaDocs) - { - hg.initLuaAndPrintDocs(); - return 0; - } - // // // ------------------------------------------------------------------------ @@ -607,6 +631,15 @@ int main(int argc, char* argv[]) server] = parseArgs(argc, argv); const auto headless = headlessB; // Workaround binding capture + // + // + // ------------------------------------------------------------------------ + // Print Lua docs mode + if(printLuaDocs) + { + return mainPrintLuaDocs(); + } + // // // ------------------------------------------------------------------------ @@ -620,6 +653,7 @@ int main(int argc, char* argv[]) // // ------------------------------------------------------------------------ // Client mode + SSVOH_ASSERT(!printLuaDocs); SSVOH_ASSERT(!server); - return mainClient(headless, printLuaDocs, args, cliLevelName, cliLevelPack); + return mainClient(headless, args, cliLevelName, cliLevelPack); } -- cgit v1.2.3 From 1ab64ec8ab4ceef63e744c057579fad8970560f7 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 20:45:27 +0100 Subject: Score/replay code refactoring and fix test --- include/SSVOpenHexagon/Core/HexagonGame.hpp | 15 ++++-- src/SSVOpenHexagon/Core/HexagonGame.cpp | 81 ++++++++++++++++++----------- test/ReplayExecution.t.cpp | 16 ++++-- 3 files changed, 75 insertions(+), 37 deletions(-) diff --git a/include/SSVOpenHexagon/Core/HexagonGame.hpp b/include/SSVOpenHexagon/Core/HexagonGame.hpp index f2874cbc..0f6661c8 100644 --- a/include/SSVOpenHexagon/Core/HexagonGame.hpp +++ b/include/SSVOpenHexagon/Core/HexagonGame.hpp @@ -245,7 +245,7 @@ private: public: // TODO (P2): For testing - std::function onReplayCreated; + std::function onDeathReplayCreated; // TODO (P2): For testing void setMustStart(const bool x) @@ -392,12 +392,21 @@ public: void newGame(const std::string& mPackId, const std::string& mId, bool mFirstPlay, float mDifficultyMult, bool executeLastReplay); + enum class SaveScoreIfNeededResult + { + NoWindow = 0, + ShouldNotSave = 1, + NotPersonalBest = 2, + PersonalBest = 3, + }; + void death(bool mForce = false); void death_shakeCamera(); - void death_sendAndSaveReplay(); + [[nodiscard]] replay_file death_createReplayFile(); void death_updateRichPresence(); - void death_saveScore(); + [[nodiscard]] SaveScoreIfNeededResult death_saveScoreIfNeeded(); void death_saveScoreIfNeededAndShowPBEffects(); + void death_sendAndSaveReplay(const replay_file& rf); [[nodiscard]] bool death_sendReplay( const std::string& levelValidator, const compressed_replay_file& crf); [[nodiscard]] bool death_saveReplay( diff --git a/src/SSVOpenHexagon/Core/HexagonGame.cpp b/src/SSVOpenHexagon/Core/HexagonGame.cpp index 2ba79210..596a5f77 100644 --- a/src/SSVOpenHexagon/Core/HexagonGame.cpp +++ b/src/SSVOpenHexagon/Core/HexagonGame.cpp @@ -827,33 +827,19 @@ void HexagonGame::death_updateRichPresence() } } -void HexagonGame::death_saveScore() -{ - SSVOH_ASSERT(shouldSaveScore()); - SSVOH_ASSERT(!inReplay()); - SSVOH_ASSERT(!levelData->unscored); - - ssvu::lo("Replay") << "Attempting to send and save replay...\n"; - death_sendAndSaveReplay(); -} - -void HexagonGame::death_saveScoreIfNeededAndShowPBEffects() +[[nodiscard]] HexagonGame::SaveScoreIfNeededResult +HexagonGame::death_saveScoreIfNeeded() { if(window == nullptr) { - return; + return SaveScoreIfNeededResult::NoWindow; } - const bool mustSaveScore = shouldSaveScore(); - - if(!mustSaveScore) + if(!shouldSaveScore()) { - playSoundAbort("gameOver.ogg"); - return; + return SaveScoreIfNeededResult::ShouldNotSave; } - death_saveScore(); // Saves local best, local replay, and sends replay - const std::string validatorWithoutPackid = levelData->getValidatorWithoutPackId(difficultyMult); @@ -863,12 +849,31 @@ void HexagonGame::death_saveScoreIfNeededAndShowPBEffects() score > assets.getLocalScore(validatorWithoutPackid); if(!isPersonalBest) + { + return SaveScoreIfNeededResult::NotPersonalBest; + } + + assets.setLocalScore(validatorWithoutPackid, score); + return SaveScoreIfNeededResult::PersonalBest; +} + +void HexagonGame::death_saveScoreIfNeededAndShowPBEffects() +{ + const SaveScoreIfNeededResult r = death_saveScoreIfNeeded(); + + if(r == SaveScoreIfNeededResult::NoWindow) + { + return; + } + + if(r == SaveScoreIfNeededResult::ShouldNotSave || + r == SaveScoreIfNeededResult::NotPersonalBest) { playSoundAbort("gameOver.ogg"); return; } - assets.setLocalScore(validatorWithoutPackid, score); + SSVOH_ASSERT(r == SaveScoreIfNeededResult::PersonalBest); pbText.setString("NEW PERSONAL BEST!"); mustSpawnPBParticles = true; @@ -902,7 +907,18 @@ void HexagonGame::death(bool mForce) status.flashEffect = 255; status.hasDied = true; - death_saveScoreIfNeededAndShowPBEffects(); + const replay_file rf = death_createReplayFile(); + + // TODO (P2): for testing + if(onDeathReplayCreated) + { + onDeathReplayCreated(rf); + } + + ssvu::lo("Replay") << "Attempting to send and save replay...\n"; + death_sendAndSaveReplay(rf); + + death_saveScoreIfNeededAndShowPBEffects(); // Saves local best if(window != nullptr && Config::getAutoRestart()) { @@ -910,14 +926,14 @@ void HexagonGame::death(bool mForce) } } -void HexagonGame::death_sendAndSaveReplay() +[[nodiscard]] replay_file HexagonGame::death_createReplayFile() { // TODO (P2): for testing const std::string rfName = assets.anyLocalProfileActive() ? assets.getCurrentLocalProfile().getName() : "no_profile"; - const replay_file rf{ + return replay_file{ ._version{0}, ._player_name{rfName}, ._seed{lastSeed}, @@ -928,12 +944,10 @@ void HexagonGame::death_sendAndSaveReplay() ._difficulty_mult{difficultyMult}, ._played_score{getReplayScore(status)}, }; +} - if(onReplayCreated) - { - onReplayCreated(rf); - } - +void HexagonGame::death_sendAndSaveReplay(const replay_file& rf) +{ const std::optional crfOpt = compress_replay_file(rf); @@ -947,6 +961,8 @@ void HexagonGame::death_sendAndSaveReplay() const compressed_replay_file& crf = crfOpt.value(); + // ------------------------------------------------------------------------ + // Send compressed replay to server. if(const std::string levelValidator = Utils::getLevelValidator(rf._level_id, rf._difficulty_mult); !death_sendReplay(levelValidator, crf)) @@ -954,6 +970,8 @@ void HexagonGame::death_sendAndSaveReplay() ssvu::lo("Replay") << "Failure sending replay\n"; } + // ------------------------------------------------------------------------ + // Save compressed replay locally. if(const std::string filename = Utils::concat(rf.create_filename(), ".gz"); !death_saveReplay(filename, crf)) { @@ -1181,7 +1199,12 @@ void HexagonGame::goToMenu(bool mSendScores, bool mError) if(mSendScores && !mError && shouldSaveScore()) { - death_saveScore(); // Saves local best, local replay, and sends replay + (void)death_saveScoreIfNeeded(); // Saves local best + + const replay_file rf = death_createReplayFile(); + + ssvu::lo("Replay") << "Attempting to send and save replay...\n"; + death_sendAndSaveReplay(rf); } // Stop infinite feedback from occurring if the error is happening on diff --git a/test/ReplayExecution.t.cpp b/test/ReplayExecution.t.cpp index e643e65c..84e802fc 100644 --- a/test/ReplayExecution.t.cpp +++ b/test/ReplayExecution.t.cpp @@ -9,9 +9,10 @@ #include "TestUtils.hpp" +#include +#include #include #include -#include int main() try @@ -58,9 +59,12 @@ try hg.alwaysSpinRight = true; } - hg::replay_file rf; + std::optional rf; - hg.onReplayCreated = [&](const hg::replay_file& newRf) { rf = newRf; }; + hg.onDeathReplayCreated = [&](const hg::replay_file& newRf) + { + rf.emplace(newRf); + }; hg.newGame(packs[i % packs.size()], levels[i % levels.size()], true /* firstPlay */, 1.f /* diffMult */, @@ -73,6 +77,8 @@ try .value() .playedTimeSeconds; + TEST_ASSERT(rf.has_value()); + std::optional score2; if(differentHG) { @@ -86,12 +92,12 @@ try }; score2 = hg2.runReplayUntilDeathAndGetScore( - rf, 1 /* maxProcessingSeconds */, 1.f /* timescale */); + rf.value(), 1 /* maxProcessingSeconds */, 1.f /* timescale */); } else { score2 = hg.runReplayUntilDeathAndGetScore( - rf, 1 /* maxProcessingSeconds */, 1.f /* timescale */); + rf.value(), 1 /* maxProcessingSeconds */, 1.f /* timescale */); } TEST_ASSERT(score2.has_value()); -- cgit v1.2.3 From 2b4440c2e5e1c5b6be5814577c8847155d8b94f9 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 5 May 2021 21:23:01 +0100 Subject: Update SFML version --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e57471ab..bf0c973e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,8 +56,8 @@ set(SFML_STATIC_LIBRARIES false) CPMAddPackage( NAME SFML - GITHUB_REPOSITORY SFML/SFML - GIT_TAG 2b79ae96d9649d26be9a3deea0862ac1ad29c19b + GITHUB_REPOSITORY SuperV1234/SFML + GIT_TAG 4e72e5d5bfa53310050b99bf69f73c5ff86419ac ) set_target_properties(sfml-system PROPERTIES UNITY_BUILD ON) -- cgit v1.2.3 From 744fd1a042aa525541239dbe69b5a0bc91810906 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Thu, 6 May 2021 09:21:15 +0100 Subject: Polish/balance bipolarity --- _RELEASE/debugldd.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 _RELEASE/debugldd.txt diff --git a/_RELEASE/debugldd.txt b/_RELEASE/debugldd.txt new file mode 100644 index 00000000..06bcbd6a --- /dev/null +++ b/_RELEASE/debugldd.txt @@ -0,0 +1,23 @@ + discord_game_sdk.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/discord_game_sdk.dll (0x7ffb47030000) + libgcc_s_seh-1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libgcc_s_seh-1.dll (0x7ffbefb40000) + libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) + libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) + libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) + libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) + libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) + libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) + libluajit.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libluajit.dll (0xc30000) + libsodium.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libsodium.dll (0x180000000) + libssp-0.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libssp-0.dll (0x7ffbef830000) + libstdc++-6.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libstdc++-6.dll (0x7ffbcdf30000) + libwinpthread-1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libwinpthread-1.dll (0x7ffbf1990000) + libzlib1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libzlib1.dll (0x4d0000) + libzlib1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libzlib1.dll (0x4d0000) + openal32.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/openal32.dll (0x7ffbe6f80000) + sdkencryptedappticket64.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sdkencryptedappticket64.dll (0x7ffbdd360000) + sfml-audio-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-audio-d-2.dll (0x62780000) + sfml-graphics-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-graphics-d-2.dll (0x68ec0000) + sfml-network-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-network-d-2.dll (0x64d40000) + sfml-system-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-system-d-2.dll (0x66080000) + sfml-window-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-window-d-2.dll (0x6e180000) + steam_api64.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/steam_api64.dll (0x7ffbeef20000) -- cgit v1.2.3 From 2196b0fe14fc80181d257feb1a0f7874ac3958ae Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Thu, 6 May 2021 09:21:44 +0100 Subject: Polish/balance bipolarity --- _RELEASE/Packs/orthoplex/Levels/bipolarity.json | 2 +- .../Packs/orthoplex/Scripts/Levels/bipolarity.lua | 44 ++++++++++++++-------- _RELEASE/debugldd.txt | 23 ----------- 3 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 _RELEASE/debugldd.txt diff --git a/_RELEASE/Packs/orthoplex/Levels/bipolarity.json b/_RELEASE/Packs/orthoplex/Levels/bipolarity.json index b50bb8a0..26478d51 100644 --- a/_RELEASE/Packs/orthoplex/Levels/bipolarity.json +++ b/_RELEASE/Packs/orthoplex/Levels/bipolarity.json @@ -8,5 +8,5 @@ "styleId": "bipolarity", "musicId": "ultima2", "luaFile": "Scripts/Levels/bipolarity.lua", - "difficultyMults": [2.0, 0.5] + "difficultyMults": [1.8, 0.5] } diff --git a/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua b/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua index d0b624d4..8d10c8e5 100644 --- a/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua +++ b/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua @@ -12,7 +12,7 @@ style = 0 lastRotationDir = 0 swapped = false rotSpeed = 0.25 -rotSpeedMax = 1 +rotSpeedMax = 0.9 FloatingWall = {} FloatingWall.__index = FloatingWall @@ -204,11 +204,17 @@ function onInit() l_setSidesMax(6) l_setIncTime(15) - l_setPulseMin(75) - l_setPulseMax(125) - l_setPulseSpeed(6.4) - l_setPulseSpeedR(6.4) - l_setPulseDelayMax(24.38) + local pulseOffset = 0 + + if u_getDifficultyMult() > 1.5 then + pulseOffset = -10 + end + + l_setPulseMin(75 + pulseOffset) + l_setPulseMax(125 + pulseOffset) + l_setPulseSpeed(5.388) + l_setPulseSpeedR(5.353) + l_setPulseDelayMax(21.38) l_setBeatPulseMax(35) beat = getBPMToBeatPulseDelay(180) / getMusicDMSyncFactor() @@ -225,6 +231,8 @@ function onInit() setDirection(u_rndInt(0, 6)) end + disableIncIfDMGreaterThan(1.5) + t_wait(12 / getMusicDMSyncFactor()) end @@ -271,18 +279,22 @@ function onUpdate(mFrameTime) fw:move(mFrameTime) end - timeAcc = timeAcc + mFrameTime - if timeAcc >= 60 * 10 then - timeAcc = 0 + if u_getDifficultyMult() <= 1.5 then + timeAcc = timeAcc + mFrameTime + if timeAcc >= 60 * 15 then + timeAcc = 0 + changes = 0 - a_playSound("levelUp.ogg") + a_playSound("levelUp.ogg") - beat = getBPMToBeatPulseDelay(180) / getMusicDMSyncFactor() - t_wait(beat*4) - t_eval([[a_playSound("increment.ogg")]]) - l_setSpeedMult(l_getSpeedMult() + l_getSpeedInc()) - if l_getSpeedMult() > l_getSpeedMax() then - l_setSpeedMult(l_getSpeedMax()) + beat = getBPMToBeatPulseDelay(180) / getMusicDMSyncFactor() + t_wait(beat * 2) + e_wait(beat * 2) + t_eval([[a_playSound("increment.ogg")]]) + l_setSpeedMult(l_getSpeedMult() + l_getSpeedInc()) + if l_getSpeedMult() > l_getSpeedMax() then + l_setSpeedMult(l_getSpeedMax()) + end end end end diff --git a/_RELEASE/debugldd.txt b/_RELEASE/debugldd.txt deleted file mode 100644 index 06bcbd6a..00000000 --- a/_RELEASE/debugldd.txt +++ /dev/null @@ -1,23 +0,0 @@ - discord_game_sdk.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/discord_game_sdk.dll (0x7ffb47030000) - libgcc_s_seh-1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libgcc_s_seh-1.dll (0x7ffbefb40000) - libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) - libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) - libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) - libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) - libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) - libImGui-SFML_d.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libImGui-SFML_d.dll (0x970000) - libluajit.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libluajit.dll (0xc30000) - libsodium.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libsodium.dll (0x180000000) - libssp-0.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libssp-0.dll (0x7ffbef830000) - libstdc++-6.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libstdc++-6.dll (0x7ffbcdf30000) - libwinpthread-1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libwinpthread-1.dll (0x7ffbf1990000) - libzlib1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libzlib1.dll (0x4d0000) - libzlib1.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/libzlib1.dll (0x4d0000) - openal32.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/openal32.dll (0x7ffbe6f80000) - sdkencryptedappticket64.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sdkencryptedappticket64.dll (0x7ffbdd360000) - sfml-audio-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-audio-d-2.dll (0x62780000) - sfml-graphics-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-graphics-d-2.dll (0x68ec0000) - sfml-network-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-network-d-2.dll (0x64d40000) - sfml-system-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-system-d-2.dll (0x66080000) - sfml-window-d-2.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/sfml-window-d-2.dll (0x6e180000) - steam_api64.dll => /c/OHWorkspace/SSVOpenHexagon/_RELEASE/steam_api64.dll (0x7ffbeef20000) -- cgit v1.2.3 From ddfc7c4c0ba2a996505d8f05040d7894d53f6823 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 19 May 2021 01:02:57 +0100 Subject: minor speed rebalance --- _RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua b/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua index 8d10c8e5..063cdf0a 100644 --- a/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua +++ b/_RELEASE/Packs/orthoplex/Scripts/Levels/bipolarity.lua @@ -190,7 +190,7 @@ timeAcc = 0 function onInit() l_setSpeedMult(5.75) l_setSpeedInc(0.25) - l_setSpeedMax(8) + l_setSpeedMax(7.75) l_setRotationSpeed(0.0) l_setRotationSpeedMax(1) l_setRotationSpeedInc(0.04) -- cgit v1.2.3 From 666ac03600f15b42d9625217ce8fe804ae303304 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 19 May 2021 01:03:59 +0100 Subject: Add bipolarity to server whitelist --- _RELEASE/config.json | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/_RELEASE/config.json b/_RELEASE/config.json index b8b98015..7ee03e70 100644 --- a/_RELEASE/config.json +++ b/_RELEASE/config.json @@ -52,7 +52,7 @@ "save_local_best_replay_to_file" : true, "server_control_port" : 50506, "server_ip" : "139.162.199.162", - "server_level_whitelist" : + "server_level_whitelist" : [ "ohvrvanilla_vittorio_romeo_cube_1_apeirogon_m_0.35", "ohvrvanilla_vittorio_romeo_cube_1_apeirogon_m_1", @@ -83,7 +83,10 @@ "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_0.6", "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_1", "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_1.8", - "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_2.2" + "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_2.2", + "ohvrvanilla_vittorio_romeo_orthoplex_1_bipolarity_m_0.5", + "ohvrvanilla_vittorio_romeo_orthoplex_1_bipolarity_m_1", + "ohvrvanilla_vittorio_romeo_orthoplex_1_bipolarity_m_1.8" ], "server_local" : true, "server_port" : 50505, @@ -96,112 +99,112 @@ "show_timer" : true, "show_tracked_variables" : true, "sound_volume" : 85.0, - "t_down" : + "t_down" : [ [ "" ], [ "" ], [ "" ], [ "" ] ], - "t_exit" : + "t_exit" : [ [ "kT" ], [ "bXButton2" ], [ "" ], [ "" ] ], - "t_focus" : + "t_focus" : [ [ "kLShift" ], [ "bXButton1" ], [ "" ], [ "" ] ], - "t_force_restart" : + "t_force_restart" : [ [ "kUp" ], [ "kR" ], [ "" ], [ "" ] ], - "t_lua_console" : + "t_lua_console" : [ [ "kF1" ], [ "" ], [ "" ], [ "" ] ], - "t_next" : + "t_next" : [ [ "kPageDown" ], [ "" ], [ "" ], [ "" ] ], - "t_pause" : + "t_pause" : [ [ "kF2" ], [ "" ], [ "" ], [ "" ] ], - "t_previous" : + "t_previous" : [ [ "kPageUp" ], [ "" ], [ "" ], [ "" ] ], - "t_replay" : + "t_replay" : [ [ "kY" ], [ "" ], [ "" ], [ "" ] ], - "t_restart" : + "t_restart" : [ [ "bMiddle" ], [ "kSpace" ], [ "kReturn" ], [ "" ] ], - "t_rotate_ccw" : + "t_rotate_ccw" : [ [ "kA" ], [ "kLeft" ], [ "bLeft" ], [ "" ] ], - "t_rotate_cw" : + "t_rotate_cw" : [ [ "kD" ], [ "kRight" ], [ "bRight" ], [ "" ] ], - "t_screenshot" : + "t_screenshot" : [ [ "kF12" ], [ "" ], [ "" ], [ "" ] ], - "t_select" : + "t_select" : [ [ "kSpace" ], [ "bMiddle" ], [ "" ], [ "" ] ], - "t_swap" : + "t_swap" : [ [ "bMiddle" ], [ "kSpace" ], [ "" ], [ "" ] ], - "t_up" : + "t_up" : [ [ "" ], [ "" ], -- cgit v1.2.3 From d36f24021ebaaa62c855a083cc4580af3035c8b1 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Wed, 19 May 2021 01:05:29 +0100 Subject: add bipolarity to ranked levels --- src/SSVOpenHexagon/Global/Config.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SSVOpenHexagon/Global/Config.cpp b/src/SSVOpenHexagon/Global/Config.cpp index e989b0bf..a52ac843 100644 --- a/src/SSVOpenHexagon/Global/Config.cpp +++ b/src/SSVOpenHexagon/Global/Config.cpp @@ -55,7 +55,10 @@ defaultServerLevelWhitelist() "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_0.6", "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_1", "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_1.8", - "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_2.2"}; + "ohvrvanilla_vittorio_romeo_cube_1_seconddimension_m_2.2", + "ohvrvanilla_vittorio_romeo_orthoplex_1_bipolarity_m_0.5", + "ohvrvanilla_vittorio_romeo_orthoplex_1_bipolarity_m_1", + "ohvrvanilla_vittorio_romeo_orthoplex_1_bipolarity_m_1.8"}; return result; } -- cgit v1.2.3