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 {
4342public:
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 () {
0 commit comments