Skip to content

Commit 0734f35

Browse files
Update to 1.20.0
1 parent eb5dc5e commit 0734f35

File tree

3 files changed

+21
-55
lines changed

3 files changed

+21
-55
lines changed

mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"_QPVersion": "0.1.1",
33
"id": "CrashMod",
44
"name": "CrashMod",
5-
"version": "0.5.0",
5+
"version": "0.6.0",
66
"author": "ComputerElite",
77
"packageId": "com.beatgames.beatsaber",
8-
"packageVersion": "1.19.1",
8+
"packageVersion": "1.20.0",
99
"modFiles": [
1010
"libCrashMod.so"
1111
],

qpm.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": [
1414
{
1515
"id": "beatsaber-hook",
16-
"versionRange": "=3.6.8",
16+
"versionRange": "^3.6.8",
1717
"additionalData": {
1818
"extraFiles": [
1919
"src/inline-hook"
@@ -29,17 +29,17 @@
2929
},
3030
{
3131
"id": "codegen",
32-
"versionRange": "=0.20.0",
32+
"versionRange": "^0.21.0",
3333
"additionalData": {}
3434
},
3535
{
3636
"id": "questui",
37-
"versionRange": "=0.13.2",
37+
"versionRange": "^0.13.2",
3838
"additionalData": {}
3939
},
4040
{
4141
"id": "custom-types",
42-
"versionRange": "=0.15.7",
42+
"versionRange": "^0.15.7",
4343
"additionalData": {}
4444
},
4545
{

src/main.cpp

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "main.hpp"
22
#include "extern/includes/config-utils/shared/config-utils.hpp"
33
#include "ModConfig.hpp"
4+
#include "GlobalNamespace/IReadonlyBeatmapData.hpp"
5+
#include "GlobalNamespace/CutScoreBuffer.hpp"
6+
#include "GlobalNamespace/ScoreModel_NoteScoreDefinition.hpp"
47
#include "GlobalNamespace/ScoreController.hpp"
58
#include "GlobalNamespace/RelativeScoreAndImmediateRankCounter.hpp"
69
#include "GlobalNamespace/StandardLevelScenesTransitionSetupDataSO.hpp"
@@ -26,6 +29,7 @@
2629
#include "GlobalNamespace/BeatmapObjectExecutionRatingsRecorder.hpp"
2730
#include "GlobalNamespace/BombNoteController.hpp"
2831
#include "GlobalNamespace/Saber.hpp"
32+
#include "GlobalNamespace/IReadonlyCutScoreBuffer.hpp"
2933

3034
#include "beatsaber-hook/shared/utils/typedefs.h"
3135
#include "beatsaber-hook/shared/utils/il2cpp-utils.hpp"
@@ -86,60 +90,22 @@ MAKE_HOOK_MATCH(BombNoteController_HandleWasCutBySaber, &BombNoteController::Han
8690
if(getModConfig().Active.GetValue() && getModConfig().CrashOnBomb.GetValue()) Crash();
8791
}
8892

89-
std::map<GlobalNamespace::ISaberSwingRatingCounter*, swingRatingCounter_context> swingRatingMap;
90-
91-
void JudgeNoContext(FlyingScoreEffect* self, NoteCutInfo& noteCutInfo) {
92-
int before;
93-
int after;
94-
int accuracy;
95-
ScoreModel::RawScoreWithoutMultiplier(noteCutInfo.swingRatingCounter, noteCutInfo.cutDistanceToCenter, byref(before), byref(after), byref(accuracy));
96-
int total = before + after + accuracy;
97-
}
98-
99-
void Judge(ISaberSwingRatingCounter* counter) {
100-
if(!getModConfig().Active.GetValue()) return;
101-
auto itr = swingRatingMap.find(counter);
102-
if(itr == swingRatingMap.end()) {
103-
getLogger().info("counter was not found in swingRatingMap!");
104-
return;
105-
}
106-
auto context = itr->second;
107-
108-
int before;
109-
int after;
110-
int accuracy;
111-
112-
ScoreModel::RawScoreWithoutMultiplier(context.noteCutInfo.swingRatingCounter, context.noteCutInfo.cutDistanceToCenter, byref(before), byref(after), byref(accuracy));
113-
int total = before + after + accuracy;
114-
if(getModConfig().CrashOn115.GetValue() && total == 115) Crash();
115-
if(context.flyingScoreEffect) {
116-
swingRatingMap.erase(itr);
117-
}
118-
}
119-
120-
MAKE_HOOK_MATCH(InitFlyingScoreEffect, &FlyingScoreEffect::InitAndPresent, void, FlyingScoreEffect* self, ByRef<NoteCutInfo> noteCutInfo, int multiplier, float duration, Vector3 targetPos, Quaternion rotation, Color color) {
121-
122-
InitFlyingScoreEffect(self, noteCutInfo, multiplier, duration, targetPos, rotation, color);
123-
124-
auto counter = noteCutInfo.heldRef.swingRatingCounter;
125-
126-
GlobalNamespace::NoteCutInfo info = noteCutInfo.heldRef;
127-
128-
swingRatingMap.insert(std::make_pair(counter, swingRatingCounter_context{info, self}));
129-
}
130-
131-
MAKE_HOOK_MATCH(HandleSwingFinish, &GlobalNamespace::BeatmapObjectExecutionRatingsRecorder_CutScoreHandler::HandleSaberSwingRatingCounterDidFinish, void, GlobalNamespace::BeatmapObjectExecutionRatingsRecorder_CutScoreHandler* self, ISaberSwingRatingCounter* counter) {
93+
MAKE_HOOK_MATCH(HandleSwingFinish, &GlobalNamespace::CutScoreBuffer::HandleSaberSwingRatingCounterDidFinish, void, GlobalNamespace::CutScoreBuffer* self, ISaberSwingRatingCounter* counter) {
13294
HandleSwingFinish(self, counter);
133-
Judge(counter);
95+
if(!getModConfig().Active.GetValue() || !getModConfig().CrashOn115.GetValue()) return;
96+
int score = self->dyn__afterCutScore() + self->dyn__beforeCutScore() + self->dyn__centerDistanceCutScore();
97+
auto *noteScoreDefinition = self->dyn__noteScoreDefinition();
98+
int maxCutScore = noteScoreDefinition->dyn_maxAfterCutScore() + noteScoreDefinition->dyn_maxBeforeCutScore() + noteScoreDefinition->dyn_maxCenterDistanceCutScore();
99+
if(score == maxCutScore) Crash();
134100
}
135101

136102
MAKE_HOOK_MATCH(RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank, &RelativeScoreAndImmediateRankCounter::UpdateRelativeScoreAndImmediateRank, void, RelativeScoreAndImmediateRankCounter* self, int score, int modifiedscore, int maxscore, int maxmodfifiedscore) {
137103
RelativeScoreAndImmediateRankCounter_UpdateRelativeScoreAndImmediateRank(self, score, modifiedscore, maxscore, maxmodfifiedscore);
138104
if(getModConfig().Active.GetValue() && getModConfig().PercentageActive.GetValue() && self->get_relativeScore() < getModConfig().Percentage.GetValue() / 100) Crash();
139105
}
140106

141-
MAKE_HOOK_MATCH(StandardLevelScenesTransitionSetupDataSO_Init, &StandardLevelScenesTransitionSetupDataSO::Init, void, StandardLevelScenesTransitionSetupDataSO* self, StringW gameMode, IDifficultyBeatmap* dbm, IPreviewBeatmapLevel* previewBeatmapLevel, OverrideEnvironmentSettings* overrideEnvironmentSettings, ColorScheme* overrideColorScheme, GameplayModifiers* gameplayModifiers, PlayerSpecificSettings* playerSpecificSettings, PracticeSettings* practiceSettings, StringW backButtonText, bool startPaused) {
142-
StandardLevelScenesTransitionSetupDataSO_Init(self, gameMode, dbm, previewBeatmapLevel, overrideEnvironmentSettings, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, backButtonText, startPaused);
107+
MAKE_HOOK_MATCH(StandardLevelScenesTransitionSetupDataSO_Init, &StandardLevelScenesTransitionSetupDataSO::Init, void, StandardLevelScenesTransitionSetupDataSO* self, StringW gameMode, IDifficultyBeatmap* dbm, IPreviewBeatmapLevel* previewBeatmapLevel, OverrideEnvironmentSettings* overrideEnvironmentSettings, ColorScheme* overrideColorScheme, GameplayModifiers* gameplayModifiers, PlayerSpecificSettings* playerSpecificSettings, PracticeSettings* practiceSettings, StringW backButtonText, bool startPaused, bool useTestNoteCutSoundEffects) {
108+
StandardLevelScenesTransitionSetupDataSO_Init(self, gameMode, dbm, previewBeatmapLevel, overrideEnvironmentSettings, overrideColorScheme, gameplayModifiers, playerSpecificSettings, practiceSettings, backButtonText, startPaused, useTestNoteCutSoundEffects);
143109
if(getModConfig().Active.GetValue()) {
144110
if(getModConfig().CrashOnPlay.GetValue() || getModConfig().CrashOnNoFailOn.GetValue() && gameplayModifiers->get_noFailOn0Energy()) Crash();
145111
if(getModConfig().CrashOnHighBPM.GetValue() && bpm > getModConfig().HighBPMValue.GetValue() || getModConfig().CrashOnLowBPM.GetValue() && bpm < getModConfig().LowBPMValue.GetValue()) Crash();
@@ -170,8 +136,8 @@ MAKE_HOOK_MATCH(SceneManager_ActiveSceneChanged, &UnityEngine::SceneManagement::
170136
}
171137
}
172138

173-
MAKE_HOOK_MATCH(ResultsViewController_Init, &ResultsViewController::Init, void, ResultsViewController* self, LevelCompletionResults* result, IDifficultyBeatmap* beatmap, bool practice, bool newHighScore) {
174-
ResultsViewController_Init(self, result, beatmap, practice, newHighScore);
139+
MAKE_HOOK_MATCH(ResultsViewController_Init, &ResultsViewController::Init, void, ResultsViewController* self, LevelCompletionResults* result, IReadonlyBeatmapData* beatmap, IDifficultyBeatmap* bm, bool practice, bool newHighScore) {
140+
ResultsViewController_Init(self, result, beatmap, bm, practice, newHighScore);
175141
if(getModConfig().Active.GetValue() && ((getModConfig().CrashOnNotFullCombo.GetValue() && !result->dyn_fullCombo()) || (getModConfig().CrashOnNewHighscore.GetValue() && self->dyn__newHighScore()))) Crash();
176142
}
177143

@@ -210,7 +176,7 @@ extern "C" void load() {
210176
INSTALL_HOOK(logger, StandardLevelScenesTransitionSetupDataSO_Init);
211177
INSTALL_HOOK(logger, SceneManager_ActiveSceneChanged);
212178
INSTALL_HOOK(logger, ResultsViewController_Init);
213-
INSTALL_HOOK(logger, InitFlyingScoreEffect);
179+
//INSTALL_HOOK(logger, InitFlyingScoreEffect);
214180
INSTALL_HOOK(logger, HandleSwingFinish);
215181
INSTALL_HOOK(logger, BombNoteController_HandleWasCutBySaber)
216182
//INSTALL_HOOK_OFFSETLESS(logger, PauseController_HandleMenuButtonTriggered, il2cpp_utils::FindMethodUnsafe("", "PauseController", "HandleMenuButtonTriggered", 0));

0 commit comments

Comments
 (0)