@@ -281,45 +281,60 @@ void setTimeStopTextStorage()
281
281
void speedUpMario ()
282
282
{
283
283
ttyd::mario::Player *player = ttyd::mario::marioGetPtr ();
284
- const uint16_t TubeMode = 22 ;
284
+ float SpeedValueToSet = 16 ;
285
+
286
+ float current_unk_184 = SpeedUpMario.MarioVar [0 ];
287
+ float current_unk_188 = SpeedUpMario.MarioVar [1 ];
288
+ float new_unk_184 = player->unk_184 ;
289
+ float new_unk_188 = player->unk_188 ;
290
+
291
+ const uint8_t NoChanges = 0 ;
292
+ const uint8_t ValuesModified = 1 ;
293
+ const uint8_t ValuesShouldBeRestored = 2 ;
285
294
286
295
if (!Cheat[SPEED_UP_MARIO].Active || ChangingCheatButtonCombo)
287
296
{
288
- // Check to see if Mario is currently in Tube Mode or not
289
- if (player-> currentMotionId == TubeMode )
297
+ // Check if the values should be restored
298
+ if (SpeedUpMario. ValuesChangedState > NoChanges )
290
299
{
291
- // marioSetSpec does not set the values for Tube Mode
292
- player->unk_184 = 1 ;
293
- player->unk_188 = 3 ;
300
+ SpeedUpMario. ValuesChangedState = 0 ;
301
+ player->unk_184 = current_unk_184 ;
302
+ player->unk_188 = current_unk_188 ;
294
303
}
295
- else
304
+ return ;
305
+ }
306
+
307
+ // Check to see if the current values have changed
308
+ if (((current_unk_184 != new_unk_184)) ||
309
+ (current_unk_188 != new_unk_188))
310
+ {
311
+ // Don't update if the new value is what was just set by this function
312
+ if (new_unk_188 != SpeedValueToSet)
296
313
{
297
- // Set the values to their default for the current character
298
- ttyd::mario::marioSetSpec ();
314
+ // Set the current values to the new values
315
+ SpeedUpMario.MarioVar [0 ] = new_unk_184;
316
+ SpeedUpMario.MarioVar [1 ] = new_unk_188;
299
317
}
300
- return ;
301
318
}
302
319
303
320
if (checkButtonComboEveryFrame (Cheat[SPEED_UP_MARIO].ButtonCombo ))
304
321
{
305
- player->wPlayerBaseSpeed = 16 ;
306
- player->unk_184 = 16 ;
307
- player->unk_188 = 16 ;
322
+ SpeedUpMario.ValuesChangedState = ValuesModified;
323
+ player->wPlayerBaseSpeed = SpeedValueToSet;
324
+ player->unk_184 = SpeedValueToSet;
325
+ player->unk_188 = SpeedValueToSet;
308
326
}
309
- else
327
+ else if (SpeedUpMario. ValuesChangedState == ValuesModified)
310
328
{
311
- // Check to see if Mario is currently in Tube Mode or not
312
- if (player->currentMotionId == TubeMode)
313
- {
314
- // marioSetSpec does not set the values for Tube Mode
315
- player->unk_184 = 1 ;
316
- player->unk_188 = 3 ;
317
- }
318
- else
319
- {
320
- // Set the values to their default for the current character
321
- ttyd::mario::marioSetSpec ();
322
- }
329
+ SpeedUpMario.ValuesChangedState = ValuesShouldBeRestored;
330
+ }
331
+
332
+ // Check if the values should be restored
333
+ if (SpeedUpMario.ValuesChangedState == ValuesShouldBeRestored)
334
+ {
335
+ SpeedUpMario.ValuesChangedState = 0 ;
336
+ player->unk_184 = SpeedUpMario.MarioVar [0 ];
337
+ player->unk_188 = SpeedUpMario.MarioVar [1 ];
323
338
}
324
339
}
325
340
0 commit comments