Skip to content

Commit

Permalink
Fixed replays viewing
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Dec 24, 2022
1 parent fafab31 commit 2618619
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
12 changes: 11 additions & 1 deletion include/ModConfig.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "config-utils/shared/config-utils.hpp"
#include "bs-utils/shared/utils.hpp"

DECLARE_CONFIG(ModConfig,

Expand All @@ -8,4 +9,13 @@ DECLARE_CONFIG(ModConfig,
CONFIG_INIT_FUNCTION(
CONFIG_INIT_VALUE(QubeSize);
)
)
)

inline bool UploadDisabledByReplay() {
for (auto kv : bs_utils::Submission::getDisablingMods()) {
if (kv.id == "Replay") {
return true;
}
}
return false;
}
7 changes: 6 additions & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
"name": "BeatLeaderModifiers",
"id": "BeatLeaderModifiers",
"author": "NSGolova",
"version": "0.1.0",
"version": "0.2.0",
"packageId": "com.beatgames.beatsaber",
"packageVersion": "1.25.1",
"coverImage": "cover.png",
"dependencies": [
{
"version": "^0.7.0",
"id": "bs-utils",
"downloadIfMissing": "https://github.com/sc2ad/QuestBS-Utils/releases/download/v0.7.2/BS-Utils.qmod"
},
{
"version": "^0.15.21",
"id": "custom-types",
Expand Down
7 changes: 6 additions & 1 deletion qpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"info": {
"name": "BeatLeaderModifiers",
"id": "BeatLeaderModifiers",
"version": "0.1.0",
"version": "0.2.0",
"url": null,
"additionalData": {
"overrideSoName": "libblmodifiers.so"
Expand Down Expand Up @@ -44,6 +44,11 @@
"id": "config-utils",
"versionRange": "^0.8.0",
"additionalData": {}
},
{
"id": "bs-utils",
"versionRange": "^0.7.0",
"additionalData": {}
}
],
"additionalData": {}
Expand Down
1 change: 0 additions & 1 deletion src/CharacteristicsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ namespace BeatLeaderModifiers {
BeatmapDifficulty defaultDifficulty,
BeatmapCharacteristicSO* defaultBeatmapCharacteristic,
PlayerData* playerData) {
getLogger().info("0");

bool inSolo = il2cpp_utils::try_cast<BeatmapLevelData>(level->get_beatmapLevelData()) != nullopt;
if (inSolo) {
Expand Down
11 changes: 7 additions & 4 deletions src/RthythmGameModifier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "include/RthythmGameModifier.hpp"
#include "include/CharacteristicsManager.hpp"
#include "include/InterpolationUtils.hpp"
#include "include/ModConfig.hpp"

#include "UnityEngine/Vector3.hpp"
#include "UnityEngine/Transform.hpp"
Expand Down Expand Up @@ -60,7 +61,7 @@ namespace BeatLeaderModifiers {
NoteController* self,
ByRef<NoteCutInfo> noteCutInfo) {

if (customCharacterisitic != CustomCharacterisitic::betterScoring || !noteMovementCache.contains(self)) {
if (UploadDisabledByReplay() || customCharacterisitic != CustomCharacterisitic::betterScoring || !noteMovementCache.contains(self)) {
NoteCut(self, noteCutInfo);
return;
}
Expand Down Expand Up @@ -122,8 +123,7 @@ namespace BeatLeaderModifiers {
}

MAKE_HOOK_MATCH(CutScoreBufferRefreshScores, &CutScoreBuffer::RefreshScores, void, CutScoreBuffer* self) {
if (customCharacterisitic == CustomCharacterisitic::betterScoring) {
getLogger().info("%f", self->noteCutInfo.timeDeviation);
if (!UploadDisabledByReplay() && customCharacterisitic == CustomCharacterisitic::betterScoring) {
float timingRating = 1 - Mathf::Clamp01((Mathf::Abs(self->noteCutInfo.timeDeviation) - goodTiming) / badTiming);
self->saberSwingRatingCounter->afterCutRating = timingRating;
self->saberSwingRatingCounter->beforeCutRating = timingRating;
Expand All @@ -145,6 +145,9 @@ namespace BeatLeaderModifiers {

MAKE_HOOK_MATCH(NoteControllerInit, &NoteController::Init, void, NoteController* self, NoteData* noteData, float worldRotation, Vector3 moveStartPos, Vector3 moveEndPos, Vector3 jumpEndPos, float moveDuration, float jumpDuration, float jumpGravity, float endRotation, float uniformScale, bool rotatesTowardsPlayer, bool useRandomRotation) {
NoteControllerInit(self, noteData, worldRotation, moveStartPos, moveEndPos, jumpEndPos, moveDuration, jumpDuration, jumpGravity, endRotation, uniformScale, rotatesTowardsPlayer, useRandomRotation);
if (UploadDisabledByReplay()) {
return;
}
float colliderScale = 0.58;
auto gameNote = il2cpp_utils::try_cast<GameNoteController>(self);
if (gameNote != std::nullopt) {
Expand Down Expand Up @@ -174,7 +177,7 @@ namespace BeatLeaderModifiers {
NoteController* self) {
NoteControllerUpdate(self);

if (audioTimeSyncController && self->get_transform()) {
if (!UploadDisabledByReplay() && audioTimeSyncController && self->get_transform()) {
if (noteMovementCache2.contains(self)) {
noteMovementCache[self] = noteMovementCache2[self];
}
Expand Down

0 comments on commit 2618619

Please sign in to comment.