Skip to content

Commit 2e2811e

Browse files
committed
might be fixed so far idk
1 parent 2d58949 commit 2e2811e

9 files changed

Lines changed: 81 additions & 340 deletions

File tree

CMakeLists.txt

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set(TOASTYREPLAY_SOURCES
1111
src/core/checkpoint_handler.cpp
1212
src/core/replay_engine.cpp
1313
src/core/checkpoint_system.cpp
14-
src/core/cbf_integration.cpp
1514
src/core/input_timing.cpp
1615
src/core/keybinds.cpp
1716
src/gui/gui.cpp
@@ -48,6 +47,23 @@ function(toastyreplay_replace_once_or_verify content_var search replacement)
4847
set(${content_var} "${updated_content}" PARENT_SCOPE)
4948
endfunction()
5049

50+
function(toastyreplay_replace_if_present content_var search replacement)
51+
string(FIND "${${content_var}}" "${replacement}" replacement_index)
52+
if (replacement_index GREATER -1)
53+
set(${content_var} "${${content_var}}" PARENT_SCOPE)
54+
return()
55+
endif()
56+
57+
string(FIND "${${content_var}}" "${search}" search_index)
58+
if (search_index EQUAL -1)
59+
set(${content_var} "${${content_var}}" PARENT_SCOPE)
60+
return()
61+
endif()
62+
63+
string(REPLACE "${search}" "${replacement}" updated_content "${${content_var}}")
64+
set(${content_var} "${updated_content}" PARENT_SCOPE)
65+
endfunction()
66+
5167
function(patch_gd_imgui_cocos_backend backend_file)
5268
file(READ "${backend_file}" backend_content)
5369

@@ -56,15 +72,21 @@ function(patch_gd_imgui_cocos_backend backend_file)
5672
"#include <Geode/Geode.hpp>"
5773
"#include <Geode/Geode.hpp>\n#include <Geode/utils/string.hpp>"
5874
)
59-
toastyreplay_replace_once_or_verify(
75+
set(toastyreplay_imgui_ini_line "static const auto iniPath = new std::string(geode::utils::string::pathToString(Mod::get()->getSaveDir() / \"imgui.ini\"));")
76+
toastyreplay_replace_if_present(
6077
backend_content
6178
"static const auto iniPath = (Mod::get()->getSaveDir() / \"imgui.ini\").string();"
62-
"static const auto iniPath = new std::string(geode::utils::string::pathToString(Mod::get()->getSaveDir() / \"imgui.ini\"));"
79+
"${toastyreplay_imgui_ini_line}"
6380
)
64-
toastyreplay_replace_once_or_verify(
81+
toastyreplay_replace_if_present(
6582
backend_content
6683
"static const auto iniPath = new std::string((Mod::get()->getSaveDir() / \"imgui.ini\").string());"
67-
"static const auto iniPath = new std::string(geode::utils::string::pathToString(Mod::get()->getSaveDir() / \"imgui.ini\"));"
84+
"${toastyreplay_imgui_ini_line}"
85+
)
86+
toastyreplay_replace_once_or_verify(
87+
backend_content
88+
"${toastyreplay_imgui_ini_line}"
89+
"${toastyreplay_imgui_ini_line}"
6890
)
6991
toastyreplay_replace_once_or_verify(
7092
backend_content

mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "5.4.1",
2+
"geode": "5.5.3",
33
"version": "v1.3.1",
44
"gd": {
55
"win": "2.2081"

src/ToastyReplay.hpp

Lines changed: 27 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "i18n/localization.hpp"
66
#include "replay.hpp"
77
#include "ttr_format.hpp"
8-
#include "core/cbf_integration.hpp"
98
#include "hacks/trajectory.hpp"
109
#include "render/renderer.hpp"
1110

@@ -43,13 +42,6 @@ class ReplayEngine {
4342
public:
4443
static constexpr double kBaseTickRate = 240.0;
4544

46-
struct QueuedMacroCommand {
47-
int button = 0;
48-
bool down = false;
49-
bool player2 = false;
50-
double timestamp = 0.0;
51-
};
52-
5345
MacroMode engineMode = MODE_DISABLED;
5446
ValidationResult validationStatus = RESULT_OK;
5547

@@ -140,11 +132,6 @@ class ReplayEngine {
140132
AccuracyMode selectedAccuracyMode = AccuracyMode::Vanilla;
141133
int tickStartStep = 0;
142134
int lastStepDelta = -1;
143-
uint64_t tickStartMicros = 0;
144-
uint64_t stepStartMicros = 0;
145-
double stepDurationMicros = 0.0;
146-
std::deque<uint64_t> pendingRawInputMicros;
147-
std::deque<QueuedMacroCommand> queuedMacroCommands;
148135

149136
int tickOffset = 0;
150137
bool startPosActive = false;
@@ -154,7 +141,6 @@ class ReplayEngine {
154141
std::vector<std::string> storedMacros;
155142
std::unordered_set<std::string> incompatibleMacros;
156143
std::unordered_set<std::string> cbsMacros;
157-
std::unordered_set<std::string> cbfMacros;
158144
std::unordered_set<std::string> ttrMacros;
159145

160146
int hotkey_tickStep = 0x56;
@@ -193,7 +179,6 @@ class ReplayEngine {
193179
storedMacros.clear();
194180
incompatibleMacros.clear();
195181
cbsMacros.clear();
196-
cbfMacros.clear();
197182
ttrMacros.clear();
198183
auto directory = geode::prelude::Mod::get()->getSaveDir() / "replays";
199184
std::error_code ec;
@@ -229,7 +214,7 @@ class ReplayEngine {
229214
uint32_t flags = 0;
230215
std::memcpy(&flags, header.data() + 6, sizeof(uint32_t));
231216
if ((flags & TTR_FLAG_ACCURACY_CBF) != 0) {
232-
cbfMacros.insert(stem);
217+
incompatibleMacros.insert(stem);
233218
} else if ((flags & TTR_FLAG_ACCURACY_CBS) != 0) {
234219
cbsMacros.insert(stem);
235220
}
@@ -253,7 +238,7 @@ class ReplayEngine {
253238
if (auto temp = MacroSequence::tryImportData(*bytes)) {
254239
storedMacros.push_back(stem);
255240
if (temp->accuracyMode == AccuracyMode::CBF) {
256-
cbfMacros.insert(stem);
241+
incompatibleMacros.insert(stem);
257242
} else if (temp->accuracyMode == AccuracyMode::CBS) {
258243
cbsMacros.insert(stem);
259244
}
@@ -272,7 +257,7 @@ class ReplayEngine {
272257
engineMode = MODE_CAPTURE;
273258
anchorReconciliation = true;
274259
resetTimingTracking();
275-
AccuracyRuntime::applyRuntimeAccuracyMode(selectedAccuracyMode);
260+
applyRuntimeAccuracyMode(selectedAccuracyMode);
276261

277262
if (ttrMode) {
278263
initializeTTRMacro(level);
@@ -341,13 +326,15 @@ class ReplayEngine {
341326
}
342327

343328
if (ttrMode && activeTTR) {
344-
if (activeTTR->accuracyMode == AccuracyMode::CBF && !AccuracyRuntime::isSyzziCBFAvailable()) {
345-
setStartPosWarningKey("CBF playback requires syzzi.click_between_frames.");
329+
if (activeTTR->accuracyMode == AccuracyMode::CBF) {
330+
startPosWarning = "CBF playback is no longer supported.";
331+
startPosWarningIsKey = false;
346332
return false;
347333
}
348334
} else if (activeMacro) {
349-
if (activeMacro->accuracyMode == AccuracyMode::CBF && !AccuracyRuntime::isSyzziCBFAvailable()) {
350-
setStartPosWarningKey("CBF playback requires syzzi.click_between_frames.");
335+
if (activeMacro->accuracyMode == AccuracyMode::CBF) {
336+
startPosWarning = "CBF playback is no longer supported.";
337+
startPosWarningIsKey = false;
351338
return false;
352339
}
353340
}
@@ -361,6 +348,7 @@ class ReplayEngine {
361348
return false;
362349
}
363350

351+
enableCBSForLoadedMacroIfNeeded();
364352
pendingPlaybackStart = false;
365353
engineMode = MODE_EXECUTE;
366354
executeIndex = 0;
@@ -379,7 +367,7 @@ class ReplayEngine {
379367
: static_cast<int>(tickRate);
380368
}
381369

382-
AccuracyRuntime::applyRuntimeAccuracyMode(activeMacroAccuracyMode());
370+
applyRuntimeAccuracyMode(activeMacroAccuracyMode());
383371
return true;
384372
}
385373

@@ -407,6 +395,9 @@ class ReplayEngine {
407395
return false;
408396
}
409397

398+
enableCBSForLoadedMacroIfNeeded();
399+
applyRuntimeAccuracyMode(selectedAccuracyMode);
400+
410401
auto* playLayer = PlayLayer::get();
411402
if (!playLayer || fastPlayback) {
412403
return beginExecutionImmediate();
@@ -441,7 +432,7 @@ class ReplayEngine {
441432
void haltExecution() {
442433
pendingPlaybackStart = false;
443434
resetTimingTracking();
444-
AccuracyRuntime::applyRuntimeAccuracyMode(selectedAccuracyMode);
435+
applyRuntimeAccuracyMode(selectedAccuracyMode);
445436
engineMode = MODE_DISABLED;
446437
}
447438

@@ -474,6 +465,18 @@ class ReplayEngine {
474465
return activeMacro ? activeMacro->accuracyMode : AccuracyMode::Vanilla;
475466
}
476467

468+
static void applyRuntimeAccuracyMode(AccuracyMode mode) {
469+
if (auto* gameManager = GameManager::get()) {
470+
gameManager->setGameVariable("0177", mode == AccuracyMode::CBS);
471+
}
472+
}
473+
474+
void enableCBSForLoadedMacroIfNeeded() {
475+
if (activeMacroAccuracyMode() == AccuracyMode::CBS) {
476+
selectedAccuracyMode = AccuracyMode::CBS;
477+
}
478+
}
479+
477480
double runtimeTickRate() const {
478481
return std::max(1.0, tickRate);
479482
}
@@ -490,52 +493,6 @@ class ReplayEngine {
490493
tickStartStep = 0;
491494
lastStepDelta = -1;
492495
respawnTickIndex = -1;
493-
tickStartMicros = 0;
494-
stepStartMicros = 0;
495-
stepDurationMicros = 0.0;
496-
pendingRawInputMicros.clear();
497-
queuedMacroCommands.clear();
498-
}
499-
500-
void beginStepTimingWindow(uint64_t stepStart, double stepDuration, bool newTick) {
501-
stepStartMicros = stepStart;
502-
stepDurationMicros = std::max(stepDuration, 1.0);
503-
if (newTick || tickStartMicros == 0) {
504-
tickStartMicros = stepStart;
505-
}
506-
}
507-
508-
void queueRawInputTimestamp(uint64_t micros) {
509-
pendingRawInputMicros.push_back(micros);
510-
while (pendingRawInputMicros.size() > 32) {
511-
pendingRawInputMicros.pop_front();
512-
}
513-
}
514-
515-
float consumeRawInputPhase(float fallbackPhase) {
516-
while (!pendingRawInputMicros.empty()) {
517-
uint64_t micros = pendingRawInputMicros.front();
518-
pendingRawInputMicros.pop_front();
519-
520-
if (tickStartMicros == 0 || stepDurationMicros <= 0.0 || micros < tickStartMicros) {
521-
continue;
522-
}
523-
524-
double elapsed = static_cast<double>(micros - tickStartMicros);
525-
double phase = elapsed / stepDurationMicros;
526-
return static_cast<float>(std::clamp(phase, 0.0, static_cast<double>(fallbackPhase) + 0.999));
527-
}
528-
529-
return fallbackPhase;
530-
}
531-
532-
void queueMacroCommand(int button, bool down, bool player2, double timestamp) {
533-
queuedMacroCommands.push_back(QueuedMacroCommand {
534-
button,
535-
down,
536-
player2,
537-
timestamp,
538-
});
539496
}
540497

541498
std::vector<PlaybackAnchor>* activeAnchors() {

src/core/cbf_integration.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/core/cbf_integration.hpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/core/input_timing.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ uint64_t InputTiming::nowMicros() {
1919
}
2020

2121
void InputTiming::queueTimestamp(uint64_t micros) {
22-
auto* engine = ReplayEngine::get();
23-
if (!engine || engine->selectedAccuracyMode != AccuracyMode::CBF || !PlayLayer::get()) {
24-
return;
25-
}
26-
27-
engine->queueRawInputTimestamp(micros);
22+
static_cast<void>(micros);
2823
}
2924

3025
void InputTiming::queueCurrentTimestamp() {
@@ -33,7 +28,6 @@ void InputTiming::queueCurrentTimestamp() {
3328

3429
class $modify(TimedTouchDispatcher, CCTouchDispatcher) {
3530
void touches(cocos2d::CCSet* touches, cocos2d::CCEvent* event, unsigned int index) {
36-
InputTiming::queueCurrentTimestamp();
3731
if (PlayLayer::get()) {
3832
Autoclicker::get()->trackUserInput(index == 0, false);
3933
}

0 commit comments

Comments
 (0)