diff options
author | Vittorio Romeo <vittorio.romeo@outlook.com> | 2021-05-19 01:08:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 01:08:57 +0100 |
commit | 62057b684db06ab614c233ff3a4d90786bb309d2 (patch) | |
tree | a940b78d26671be79a373778537c362c11bbc62a | |
parent | 103aa2df242cf43e18386d8f9e5ed44a32742671 (diff) | |
parent | d36f24021ebaaa62c855a083cc4580af3035c8b1 (diff) |
Merge pull request #339 from SuperV1234/2.0.6v2.0.6
Open Hexagon v2.0.6
47 files changed, 707 insertions, 308 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ec451d7..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 c0b19109a97481a1edf8551e66b2a3993c7cce6d + GITHUB_REPOSITORY SuperV1234/SFML + GIT_TAG 4e72e5d5bfa53310050b99bf69f73c5ff86419ac ) 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/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..063cdf0a 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 @@ -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) @@ -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/config.json b/_RELEASE/config.json index bb06c50c..7ee03e70 100644 --- a/_RELEASE/config.json +++ b/_RELEASE/config.json @@ -52,6 +52,42 @@ "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",
+ "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,
"server_verbose" : true,
@@ -63,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" :
[
[ "" ],
[ "" ],
diff --git a/_RELEASE/sdkencryptedappticket64.lib b/_RELEASE/sdkencryptedappticket64.lib Binary files differnew file mode 100644 index 00000000..25216dc0 --- /dev/null +++ b/_RELEASE/sdkencryptedappticket64.lib diff --git a/art/a35_eagerformore_l.png b/art/a35_eagerformore_l.png Binary files differnew file mode 100644 index 00000000..45410170 --- /dev/null +++ b/art/a35_eagerformore_l.png diff --git a/art/a35_eagerformore_u.png b/art/a35_eagerformore_u.png Binary files differnew file mode 100644 index 00000000..90179100 --- /dev/null +++ b/art/a35_eagerformore_u.png diff --git a/art/eventcover.psd b/art/eventcover.psd Binary files differindex afbde42b..2709a8b2 100644 --- a/art/eventcover.psd +++ b/art/eventcover.psd 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/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_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/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/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\ 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 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<sf::Vector2f, 4>& + [[nodiscard, gnu::always_inline]] const std::array<sf::Vector2f, 4>& getVertexPositions() const noexcept { return _vertexPositions; } - [[gnu::always_inline, nodiscard]] const std::array<sf::Vector2f, 4>& + [[nodiscard, gnu::always_inline]] const std::array<sf::Vector2f, 4>& 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<sf::Vector2f, 4>& + [[nodiscard, gnu::always_inline]] const std::array<sf::Vector2f, 4>& 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/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<void(const replay_file&)> onReplayCreated; + std::function<void(const replay_file&)> 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/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 <SSVStart/Camera/Camera.hpp> @@ -109,7 +110,7 @@ private: ssvs::GameWindow& window; HexagonClient& hexagonClient; HexagonDialogBox dialogBox; - std::unique_ptr<LeaderboardCache> leaderboardCache; + Utils::UniquePtr<LeaderboardCache> leaderboardCache; Lua::LuaContext lua; std::vector<std::string> 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 <cstdint> #include <functional> -#include <memory> #include <optional> #include <string_view> #include <string> @@ -18,7 +19,7 @@ class steam_manager private: class steam_manager_impl; - std::unique_ptr<steam_manager_impl> _impl; + Utils::UniquePtr<steam_manager_impl> _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 <string> -#include <memory> namespace sf { @@ -22,7 +23,7 @@ class AssetStorage private: class AssetStorageImpl; - std::unique_ptr<AssetStorageImpl> _impl; + Utils::UniquePtr<AssetStorageImpl> _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 <cstddef> #include <map> -#include <memory> #include <string> #include <unordered_map> #include <vector> @@ -46,7 +47,7 @@ private: bool levelsOnly{false}; - std::unique_ptr<AssetStorage> assetStorage; + Utils::UniquePtr<AssetStorage> assetStorage; std::unordered_map<std::string, LevelData> levelDatas; std::unordered_map<std::string, std::vector<std::string>> 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 <string> -#include <memory> #include <functional> namespace sf { @@ -26,7 +27,7 @@ public: private: class AudioImpl; - std::unique_ptr<AudioImpl> _impl; + Utils::UniquePtr<AudioImpl> _impl; [[nodiscard]] const AudioImpl& impl() const noexcept; [[nodiscard]] AudioImpl& impl() noexcept; 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 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<R (F::*)(Args...)> using Return = R; using Function = F; - inline static constexpr std::size_t numArgs = sizeof...(Args); + enum + { + numArgs = sizeof...(Args) + }; template <std::size_t I> using NthArg = std::tuple_element_t<I, std::tuple<Args...>>; }; template <typename R, typename F, typename... Args> -struct ArgExtractor<R (F::*)(Args...) const> +struct ArgExtractor<R (F::*)(Args...) const> : ArgExtractor<R (F::*)(Args...)> { - using Return = R; - using Function = F; - - inline static constexpr std::size_t numArgs = sizeof...(Args); - - template <std::size_t I> - using NthArg = std::tuple_element_t<I, std::tuple<Args...>>; + using ArgExtractor<R (F::*)(Args...)>::NthArg; }; } // namespace hg::Utils 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 <typename T> -[[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<std::size_t>(value); diff --git a/include/SSVOpenHexagon/Utils/FastVertexVector.hpp b/include/SSVOpenHexagon/Utils/FastVertexVector.hpp index 25d92023..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 <SFML/Graphics/Color.hpp> #include <SFML/Graphics/PrimitiveType.hpp> #include <SFML/Graphics/Drawable.hpp> @@ -16,7 +18,6 @@ #include <cstddef> #include <cstring> -#include <memory> 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<VertexUnion[]> _data{nullptr}; + Utils::UniquePtrArray<VertexUnion> _data{nullptr}; std::size_t _size{}; std::size_t _capacity{}; @@ -54,7 +55,7 @@ public: return; } - auto new_data = std::make_unique<VertexUnion[]>(n); + auto new_data = Utils::makeUniqueArray<VertexUnion>(n); if(SSVU_UNLIKELY(_data != nullptr)) { @@ -94,7 +95,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; } @@ -129,11 +130,11 @@ public: } // UB: - mRenderTarget.draw(reinterpret_cast<sf::Vertex*>(_data.get()), _size, - TPrimitive, mRenderStates); + mRenderTarget.draw(reinterpret_cast<const sf::Vertex*>(_data.get()), + _size, 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 +143,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); 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 <typename... Ts> [[nodiscard]] static std::string typeToStr(TypeWrapper<std::tuple<Ts...>>); - template <typename ArgT> - static void addTypeToStr(std::vector<std::string>& types) - { - types.emplace_back(typeToStr(TypeWrapper<std::decay_t<ArgT>>{})); - } - template <typename FOp> [[nodiscard]] static std::string makeArgsString(LuaMetadataProxy* self) { using AE = Utils::ArgExtractor<FOp>; - std::vector<std::string> types; - - [&]<std::size_t... Is>(std::index_sequence<Is...>) - { - (addTypeToStr<typename AE::template NthArg<Is>>(types), ...); - } - (std::make_index_sequence<AE::numArgs>{}); - - 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<std::decay_t<typename AE::template NthArg<0>>>{}); + + 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::size_t... Is>(std::index_sequence<Is...>) + { + (( // + res += typeToStr(TypeWrapper< + std::decay_t<typename AE::template NthArg<Is>>>{}), // + res += ' ', // + res += self->argNames.at(Is), // + res += ", "), + ...); + } + (std::make_index_sequence<AE::numArgs>{}); + + res.pop_back(); + res.pop_back(); - return res; + return res; + } } [[nodiscard]] std::string resolveArgNames(const std::string& docs); - template <typename FOp> + template <typename Ret> [[nodiscard]] static std::string makeErasedRet(LuaMetadataProxy*) { - using AE = Utils::ArgExtractor<FOp>; - return typeToStr(TypeWrapper<std::decay_t<typename AE::Return>>{}); + return typeToStr(TypeWrapper<std::decay_t<Ret>>{}); } public: @@ -91,7 +92,7 @@ public: TypeWrapper<F>, LuaMetadata& mLuaMetadata, const std::string& mName) : luaMetadata{mLuaMetadata}, name{mName}, - erasedRet{&makeErasedRet<FOp>}, + erasedRet{&makeErasedRet<typename Utils::ArgExtractor<FOp>::Return>}, erasedArgs{&makeArgsString<FOp>} {} 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 <typename... TArgs> struct FnTupleWrapper<void(TArgs...)> { - static constexpr int count{sizeof...(TArgs)}; + enum + { + count = sizeof...(TArgs) + }; using ParamsType = std::tuple<TArgs...>; template <typename T> @@ -87,7 +90,10 @@ struct FnTupleWrapper<void(TArgs...)> template <typename R, typename... TArgs> struct FnTupleWrapper<R(TArgs...)> { - static constexpr int count{sizeof...(TArgs)}; + enum + { + count = sizeof...(TArgs) + }; using ParamsType = std::tuple<TArgs...>; template <typename T> @@ -884,8 +890,8 @@ public: template <typename Key, typename Value, typename... Args> void insert(Key&& k, Value&& v, Args&&... args) { - typedef typename ToPushableType<std::decay_t<Key>>::type RKey; - typedef typename ToPushableType<std::decay_t<Value>>::type RValue; + using RKey = typename ToPushableType<std::decay_t<Key>>::type; + using RValue = typename ToPushableType<std::decay_t<Value>>::type; _elements.emplace_back(new Element<RKey, RValue>( std::forward<Key>(k), std::forward<Value>(v))); @@ -1070,110 +1076,111 @@ private: return 1; } + template <typename FunctionPushType> + 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 <typename FunctionPushType> + 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<int (lua_State*)>'s destructor + SSVOH_ASSERT(lua_gettop(lua) == 1); + + auto function = (FunctionPushType*)lua_touserdata(lua, 1); + + SSVOH_ASSERT(function); + function->~FunctionPushType(); + + return 0; + } + + template <typename F, typename Op> + struct FunctionToPush + { + LuaContext* _ctx; + F _fn; + + auto operator()(lua_State* state) const + { + SSVOH_ASSERT(_ctx->_state == state); + + // FnTupleWrapper<FnType> 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<Op>::Type; + using TupledFunction = FnTupleWrapper<FnType>; + + // 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<typename TupledFunction::ParamsType*>( + 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 <typename T, typename Op = decltype(&std::decay_t<T>::operator())> + template <typename T, typename DecayT = std::decay_t<T>, + 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<Op>::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<T>(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<FnType> 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<FnType>; - - // 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<typename TupledFunction::ParamsType*>( - 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<int (lua_State*)>'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<DecayT, Op>; // 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<T>(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<FunctionPushType>); lua_settable(_state, -3); + lua_pushstring(_state, "_typeid"); lua_pushlightuserdata(_state, const_cast<std::type_info*>(&typeid(T))); lua_settable(_state, -3); + lua_pushstring(_state, "__gc"); - lua_pushcfunction(_state, callbackGarbage); + lua_pushcfunction(_state, &callbackGarbage<FunctionPushType>); 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<T>* ptr = - (std::shared_ptr<T>*)lua_touserdata(lua, 1); + auto* ptr = (std::shared_ptr<T>*)lua_touserdata(lua, 1); SSVOH_ASSERT(ptr && *ptr); ptr->~shared_ptr(); @@ -1516,24 +1525,6 @@ return table;*/ }; template <typename T> -struct IsFunctor -{ - using one = char; - using two = long; - - template <typename C> - static one test(decltype(&C::operator())); - - template <typename C> - static two test(...); - - enum - { - value = sizeof(test<T>(0)) == sizeof(char) - }; -}; - -template <typename T> struct LuaContext::ToPushableType<T&> { using type = typename ToPushableType<T>::type; @@ -1607,7 +1598,7 @@ struct LuaContext::ToPushableType<LuaContext::Table> }; template <typename T> -struct LuaContext::ToPushableType<T, std::enable_if_t<IsFunctor<T>::value>> +struct LuaContext::ToPushableType<T, decltype(&T::operator(), void())> { 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 <typename T> +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 <typename T, typename... Ts> +[[nodiscard, gnu::always_inline]] inline UniquePtr<T> makeUnique(Ts&&... xs) +{ + return UniquePtr<T>{new T{static_cast<Ts&&>(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 <typename T> +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 <typename T> +[[nodiscard, gnu::always_inline]] inline UniquePtrArray<T> makeUniqueArray( + decltype(sizeof(int)) capacity) +{ + return UniquePtrArray<T>{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 <SSVStart/SoundPlayer/SoundPlayer.hpp> @@ -14,7 +16,6 @@ #include <SFML/Audio/SoundBuffer.hpp> #include <SFML/Audio/Music.hpp> -#include <memory> #include <optional> #include <string> @@ -190,7 +191,7 @@ public: Audio::Audio(const SoundBufferGetter& soundBufferGetter, const MusicPathGetter& musicPathGetter) - : _impl{std::make_unique<AudioImpl>(soundBufferGetter, musicPathGetter)} + : _impl{Utils::makeUnique<AudioImpl>(soundBufferGetter, musicPathGetter)} {} Audio::~Audio() = default; 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); @@ -864,11 +850,30 @@ void HexagonGame::death_saveScoreIfNeededAndShowPBEffects() 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<compressed_replay_file> 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/src/SSVOpenHexagon/Core/MenuGame.cpp b/src/SSVOpenHexagon/Core/MenuGame.cpp index c98dcd42..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 <SSVStart/Input/Input.hpp> @@ -155,7 +156,7 @@ MenuGame::MenuGame(Steam::steam_manager& mSteamManager, window(mGameWindow), hexagonClient{mHexagonClient}, dialogBox(imagine, mGameWindow), - leaderboardCache{std::make_unique<LeaderboardCache>()}, + leaderboardCache{Utils::makeUnique<LeaderboardCache>()}, lua{}, execScriptPackPathContext{}, currentPack{nullptr}, @@ -313,6 +314,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; 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<unsigned long>(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; }; 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 <SSVUtils/Core/Log/Log.hpp> #include <stdint.h> // 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_impl>()} +steam_manager::steam_manager() : _impl{Utils::makeUnique<steam_manager_impl>()} {} steam_manager::~steam_manager() = default; 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 @@ -159,6 +159,36 @@ std::optional<std::string> getFirstCompressedReplayFilenameFromArgs( // // // ---------------------------------------------------------------------------- +// 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; +} + +// +// +// ---------------------------------------------------------------------------- // Server main entrypoint // ---------------------------------------------------------------------------- @@ -202,7 +232,7 @@ std::optional<std::string> getFirstCompressedReplayFilenameFromArgs( // Client main entrypoint // ---------------------------------------------------------------------------- -[[nodiscard]] int mainClient(const bool headless, const bool printLuaDocs, +[[nodiscard]] int mainClient(const bool headless, const std::vector<std::string>& args, const std::optional<std::string>& cliLevelName, const std::optional<std::string>& cliLevelPack) @@ -359,12 +389,6 @@ std::optional<std::string> getFirstCompressedReplayFilenameFromArgs( &hc // }; - if(printLuaDocs) - { - hg.initLuaAndPrintDocs(); - return 0; - } - // // // ------------------------------------------------------------------------ @@ -610,6 +634,15 @@ int main(int argc, char* argv[]) // // // ------------------------------------------------------------------------ + // Print Lua docs mode + if(printLuaDocs) + { + return mainPrintLuaDocs(); + } + + // + // + // ------------------------------------------------------------------------ // Server mode if(server) { @@ -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); } 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 <SFML/Graphics/Font.hpp> #include <SFML/Graphics/Image.hpp> @@ -14,7 +16,6 @@ #include <SFML/Audio/SoundBuffer.hpp> #include <string> -#include <memory> #include <unordered_map> namespace hg { @@ -114,7 +115,7 @@ AssetStorage::impl() const noexcept return *_impl; } -AssetStorage::AssetStorage() : _impl{std::make_unique<AssetStorageImpl>()} +AssetStorage::AssetStorage() : _impl{Utils::makeUnique<AssetStorageImpl>()} {} 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 <SSVUtils/Core/FileSystem/FileSystem.hpp> @@ -115,7 +120,7 @@ HGAssets::HGAssets( Steam::steam_manager* mSteamManager, bool mHeadless, bool mLevelsOnly) : steamManager{mSteamManager}, levelsOnly{mLevelsOnly}, - assetStorage{std::make_unique<AssetStorage>()} + assetStorage{Utils::makeUnique<AssetStorage>()} { using Clock = std::chrono::high_resolution_clock; using TimePoint = std::chrono::time_point<Clock>; 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; } 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 ) 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 <array> +#include <optional> #include <random> #include <stdexcept> -#include <array> int main() try @@ -58,9 +59,12 @@ try hg.alwaysSpinRight = true; } - hg::replay_file rf; + std::optional<hg::replay_file> 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<hg::HexagonGame::GameExecutionResult> 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()); |