Skip to content

Commit

Permalink
Fix multiplayer crash and add text
Browse files Browse the repository at this point in the history
  • Loading branch information
kodenamekrak committed Jan 25, 2023
1 parent b1f89f8 commit 4e1a247
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 8 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Credit to darknight1050 https://github.com/darknight1050/CrashReporter/blob/master/.github/workflows/build-ndk.yml

name: NDK build

env:
module_id: practiceaddons
qmodName: PracticeAddons

on:
workflow_dispatch:
push:
branches-ignore:
- 'version-v*'
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
name: Checkout
with:
submodules: true
lfs: true

- uses: seanmiddleditch/gha-setup-ninja@v3

- name: Create ndkpath.txt
run: |
echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt
cat ${GITHUB_WORKSPACE}/ndkpath.txt
- name: Get QPM
if: steps.cache-qpm.outputs.cache-hit != 'true'
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: cargo-build.yml
name: linux-qpm-rust
path: QPM
repo: QuestPackageManager/QPM.CLI

- name: QPM Collapse
run: |
chmod +x ./QPM/qpm-rust
./QPM/qpm-rust collapse
- name: QPM Dependencies Cache
id: cache-qpm-deps
uses: actions/cache@v2
env:
cache-name: cache-qpm-deps
with:
path: /home/runner/.local/share/QPM-Rust/cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: QPM Restore
run: |
./QPM/qpm-rust restore
- name: List Post Restore
run: |
echo includes:
ls -la ${GITHUB_WORKSPACE}/extern/includes
echo libs:
ls -la ${GITHUB_WORKSPACE}/extern/libs
echo cache:
ls -la $HOME/.local/share/QPM-Rust/cache
- name: Build
run: |
cd ${GITHUB_WORKSPACE}
./QPM/qpm-rust qmod build
pwsh -Command ./build.ps1
- name: Create Qmod
run: |
pwsh -Command ./createqmod.ps1 ${{env.qmodName}}
- name: Get Library Name
id: libname
run: |
cd ./build/
pattern="lib${module_id}*.so"
files=( $pattern )
echo ::set-output name=NAME::"${files[0]}"
- name: Upload so artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.libname.outputs.NAME }}
path: ./build/${{ steps.libname.outputs.NAME }}
if-no-files-found: error

- name: Upload qmod artifact
uses: actions/upload-artifact@v2
with:
name: ${{env.qmodName}}.qmod
path: ./${{ env.qmodName }}.qmod
if-no-files-found: error
2 changes: 0 additions & 2 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const std::string configPath = "/sdcard/moddata/com.beatgames.beatsaber/mods/Pra

PracticeAddons::Config::Levels levels;
PracticeAddons::Config::Difficulty* currentDifficulty;
std::string currentLevelId;

namespace PracticeAddons::Config {

Expand All @@ -25,7 +24,6 @@ namespace PracticeAddons::Config {

Difficulty GetLevelInfo(std::string levelId, std::string characteristic, std::string difficulty)
{
currentLevelId = levelId;
bool exists = levels.levels[levelId].characteristics[characteristic].difficulties.contains(difficulty);
currentDifficulty = &levels.levels[levelId].characteristics[characteristic].difficulties[difficulty];

Expand Down
14 changes: 8 additions & 6 deletions src/Hooks/RestartHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "GlobalNamespace/PauseController.hpp"
#include "GlobalNamespace/ILevelRestartController.hpp"
#include "GlobalNamespace/SinglePlayerLevelSelectionFlowCoordinator.hpp"
#include "GlobalNamespace/MultiplayerLevelScenesTransitionSetupDataSO.hpp"

#include "UnityEngine/Resources.hpp"

Expand All @@ -25,23 +26,24 @@ MAKE_HOOK_MATCH(AudioTimeSyncController_Update, &GlobalNamespace::AudioTimeSyncC
}
}

MAKE_HOOK_MATCH(AudioTimeSyncController_Start, &GlobalNamespace::AudioTimeSyncController::Start, void, GlobalNamespace::AudioTimeSyncController* self)
MAKE_HOOK_MATCH(SinglePlayerLevelSelectionFlowCoordinator_StartLevel, &GlobalNamespace::SinglePlayerLevelSelectionFlowCoordinator::StartLevel, void, GlobalNamespace::SinglePlayerLevelSelectionFlowCoordinator* self, System::Action* beforeSceneSwitchCallback, bool practice)
{
AudioTimeSyncController_Start(self);
SinglePlayerLevelSelectionFlowCoordinator_StartLevel(self, beforeSceneSwitchCallback, practice);
isPractice = practice;
shouldReset = true;
}

MAKE_HOOK_MATCH(SinglePlayerLevelSelectionFlowCoordinator_StartLevel, &GlobalNamespace::SinglePlayerLevelSelectionFlowCoordinator::StartLevel, void, GlobalNamespace::SinglePlayerLevelSelectionFlowCoordinator* self, System::Action* beforeSceneSwitchCallback, bool practice)
MAKE_HOOK_MATCH(MultiplayerLevelScenesTransitionSetupDataSO_Init, &GlobalNamespace::MultiplayerLevelScenesTransitionSetupDataSO::Init, void, GlobalNamespace::MultiplayerLevelScenesTransitionSetupDataSO* self, StringW gameMode, GlobalNamespace::IPreviewBeatmapLevel* previewBeatmapLevel, GlobalNamespace::BeatmapDifficulty beatmapDifficulty, GlobalNamespace::BeatmapCharacteristicSO* beatmapCharacteristic, GlobalNamespace::IDifficultyBeatmap* difficultyBeatmap, GlobalNamespace::ColorScheme* overrideColorScheme, GlobalNamespace::GameplayModifiers* gameplayModifiers, GlobalNamespace::PlayerSpecificSettings* playerSpecificSettings, GlobalNamespace::PracticeSettings* practiceSettings, bool useTestNoteCutSoundEffects)
{
SinglePlayerLevelSelectionFlowCoordinator_StartLevel(self, beforeSceneSwitchCallback, practice);
isPractice = practice;
MultiplayerLevelScenesTransitionSetupDataSO_Init(self, gameMode, previewBeatmapLevel, beatmapDifficulty, beatmapCharacteristic, difficultyBeatmap, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, useTestNoteCutSoundEffects);
isPractice = false;
}

namespace PracticeAddons::Hooks {
void InstallRestartHooks()
{
INSTALL_HOOK(getLogger(), MultiplayerLevelScenesTransitionSetupDataSO_Init);
INSTALL_HOOK(getLogger(), AudioTimeSyncController_Update);
INSTALL_HOOK(getLogger(), AudioTimeSyncController_Start);
INSTALL_HOOK(getLogger(), SinglePlayerLevelSelectionFlowCoordinator_StartLevel);
}
}
1 change: 1 addition & 0 deletions src/SliderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace PracticeAddons::SliderManager {
resetTrans->set_anchoredPosition({-25, -57});

restartSlider->valueDidChangeEvent = custom_types::MakeDelegate<System::Action_2<HMUI::RangeValuesTextSlider* , float>*>(std::function(PlayPreview));
QuestUI::BeatSaberUI::CreateText(parent, "Song Restart", {21, -16});
}

void HandleSliderValues(HMUI::PercentSlider* speedSlider, HMUI::TimeSlider* startSlider)
Expand Down

0 comments on commit 4e1a247

Please sign in to comment.