@@ -3433,7 +3433,8 @@ void *initStageEvents()
3433
3433
WarpByEvent.ShouldInit = false ;
3434
3434
int32_t StageAndEventIds[2 ];
3435
3435
3436
- if (!indexToStageAndEvent (WarpByEvent.CurrentIndex , StageAndEventIds))
3436
+ int32_t CurrentIndex = WarpByEvent.CurrentIndex ;
3437
+ if (!indexToStageAndEvent (CurrentIndex, StageAndEventIds))
3437
3438
{
3438
3439
// The overwritten instruction sets r3 to the global work pointer, so return the global work pointer
3439
3440
return ttyd::mariost::globalWorkPointer;
@@ -3448,6 +3449,19 @@ void *initStageEvents()
3448
3449
return ttyd::mariost::globalWorkPointer;
3449
3450
}
3450
3451
3452
+ // Back up the standard inventory if desired
3453
+ int16_t StandardInventory[20 ];
3454
+ void *StandardInventoryStartPtr = nullptr ;
3455
+
3456
+ bool ShouldKeepInventory = WarpByEvent.ShouldKeepInventory ;
3457
+ if (ShouldKeepInventory)
3458
+ {
3459
+ StandardInventoryStartPtr = reinterpret_cast <void *>(
3460
+ reinterpret_cast <uint32_t >(ttyd::mario_pouch::pouchGetPtr ()) + 0x192 );
3461
+
3462
+ memcpy (StandardInventory, StandardInventoryStartPtr, sizeof (StandardInventory));
3463
+ }
3464
+
3451
3465
// Clear all current states
3452
3466
ttyd::swdrv::swInit ();
3453
3467
@@ -3467,6 +3481,21 @@ void *initStageEvents()
3467
3481
}
3468
3482
}
3469
3483
3484
+ // Restore the standard inventory if desired
3485
+ if (ShouldKeepInventory)
3486
+ {
3487
+ memcpy (StandardInventoryStartPtr, StandardInventory, sizeof (StandardInventory));
3488
+
3489
+ /* If the player warped to the event with the index of 278, then they should be
3490
+ given a Coconut, as it is used to get the Chuckola Cola from Flavio*/
3491
+
3492
+ if (CurrentIndex == 278 )
3493
+ {
3494
+ // Only add the item if the player has a free inventory slot for it
3495
+ ttyd::mario_pouch::pouchGetItem (ttyd::item_data::Item::Coconut);
3496
+ }
3497
+ }
3498
+
3470
3499
// Set the Sequence to the value for the current event
3471
3500
setSequencePosition (getGsw0ForEvent (StageId, EventId));
3472
3501
0 commit comments