@@ -5380,77 +5380,43 @@ CustomStateStruct *resizeStateMemory(CustomStateStruct *state, uint32_t numEntri
5380
5380
return state;
5381
5381
}
5382
5382
5383
- char * createCustomState ( )
5383
+ void setCustomStateData (CustomStateStruct *state )
5384
5384
{
5385
- uint32_t tempTotalEntries = CustomState.TotalEntries ;
5386
- CustomStateStruct *tempState = CustomState.State ;
5387
-
5388
- if (tempTotalEntries == 0 )
5389
- {
5390
- // No custom states exist, so create one
5391
- if (tempState)
5392
- {
5393
- delete[] (tempState);
5394
- }
5395
-
5396
- tempState = new CustomStateStruct;
5397
- CustomState.State = tempState;
5398
-
5399
- tempTotalEntries = 1 ;
5400
- CustomState.TotalEntries = tempTotalEntries;
5401
- }
5402
- else if (tempTotalEntries >= CUSTOM_STATES_MAX_COUNT)
5403
- {
5404
- // Maximum number of states have been made
5405
- return nullptr ;
5406
- }
5407
- else
5408
- {
5409
- tempState = resizeStateMemory (tempState, tempTotalEntries, 1 );
5410
- CustomState.State = tempState;
5411
-
5412
- tempTotalEntries++;
5413
- CustomState.TotalEntries = tempTotalEntries;
5414
- }
5415
-
5416
- // Set the info for the new state
5417
- tempState = &tempState[tempTotalEntries - 1 ];
5418
-
5419
5385
// Back up the inventory
5420
5386
uint32_t PouchPtr = reinterpret_cast <uint32_t >(ttyd::mario_pouch::pouchGetPtr ());
5421
5387
5422
5388
// Standard items
5423
5389
memcpy (
5424
- tempState ->StandardItems ,
5390
+ state ->StandardItems ,
5425
5391
reinterpret_cast <void *>(PouchPtr + 0x192 ),
5426
- sizeof (tempState ->StandardItems ));
5392
+ sizeof (state ->StandardItems ));
5427
5393
5428
5394
// Important items
5429
5395
memcpy (
5430
- tempState ->ImportantItems ,
5396
+ state ->ImportantItems ,
5431
5397
reinterpret_cast <void *>(PouchPtr + 0xA0 ),
5432
- sizeof (tempState ->ImportantItems ));
5398
+ sizeof (state ->ImportantItems ));
5433
5399
5434
5400
// Badges
5435
5401
memcpy (
5436
- tempState ->Badges ,
5402
+ state ->Badges ,
5437
5403
reinterpret_cast <void *>(PouchPtr + 0x1FA ),
5438
- sizeof (tempState ->Badges ));
5404
+ sizeof (state ->Badges ));
5439
5405
5440
5406
// Equipped badges
5441
5407
memcpy (
5442
- tempState ->EquippedBadges ,
5408
+ state ->EquippedBadges ,
5443
5409
reinterpret_cast <void *>(PouchPtr + 0x38A ),
5444
- sizeof (tempState ->EquippedBadges ));
5410
+ sizeof (state ->EquippedBadges ));
5445
5411
5446
5412
// Stored items
5447
5413
memcpy (
5448
- tempState ->StoredItems ,
5414
+ state ->StoredItems ,
5449
5415
reinterpret_cast <void *>(PouchPtr + 0x1BA ),
5450
- sizeof (tempState ->StoredItems ));
5416
+ sizeof (state ->StoredItems ));
5451
5417
5452
5418
// Back up some of Mario's data
5453
- CustomStateMarioVars *MarioVars = &tempState ->MarioVars ;
5419
+ CustomStateMarioVars *MarioVars = &state ->MarioVars ;
5454
5420
MarioVars->currentHP = *reinterpret_cast <int16_t *>(PouchPtr + 0x70 );
5455
5421
MarioVars->maxHP = *reinterpret_cast <int16_t *>(PouchPtr + 0x72 );
5456
5422
MarioVars->currentFP = *reinterpret_cast <int16_t *>(PouchPtr + 0x74 );
@@ -5469,49 +5435,86 @@ char *createCustomState()
5469
5435
5470
5436
// Back up the partner data
5471
5437
memcpy (
5472
- tempState ->PartyData ,
5438
+ state ->PartyData ,
5473
5439
reinterpret_cast <void *>(PouchPtr + sizeof (ttyd::mario_pouch::PouchPartyData)),
5474
- sizeof (tempState ->PartyData ));
5440
+ sizeof (state ->PartyData ));
5475
5441
5476
5442
// Back up the sequence position
5477
- tempState ->SequencePosition = getSequencePosition ();
5443
+ state ->SequencePosition = getSequencePosition ();
5478
5444
5479
5445
// Back up which partner is currently out
5480
5446
ttyd::mario::Player *player = ttyd::mario::marioGetPtr ();
5481
5447
uint32_t PartnerPtr = reinterpret_cast <uint32_t >(getPartnerPointer ());
5482
5448
if (PartnerPtr)
5483
5449
{
5484
- tempState ->PartnerOut = player->prevFollowerId [0 ];
5450
+ state ->PartnerOut = player->prevFollowerId [0 ];
5485
5451
}
5486
5452
5487
5453
// Back up which follower is currently out
5488
5454
uint32_t FollowerPtr = reinterpret_cast <uint32_t >(getFollowerPointer ());
5489
5455
if (FollowerPtr)
5490
5456
{
5491
- tempState ->FollowerOut = player->prevFollowerId [1 ];
5457
+ state ->FollowerOut = player->prevFollowerId [1 ];
5492
5458
}
5493
5459
5494
5460
// Back up if Mario is currently using Boat Mode or not
5495
5461
if (player->currentMotionId == ttyd::mario_motion::MarioMotions::kShip )
5496
5462
{
5497
- tempState ->MarioIsShip = true ;
5463
+ state ->MarioIsShip = true ;
5498
5464
}
5499
5465
else
5500
5466
{
5501
- tempState ->MarioIsShip = false ;
5467
+ state ->MarioIsShip = false ;
5502
5468
}
5503
5469
5504
5470
// Back up the current map
5505
5471
strncpy (
5506
- tempState ->CurrentMap ,
5472
+ state ->CurrentMap ,
5507
5473
ttyd::seq_mapchange::NextMap,
5508
- sizeof (tempState ->CurrentMap ));
5474
+ sizeof (state ->CurrentMap ));
5509
5475
5510
5476
// Back up the current loading zone
5511
5477
strncpy (
5512
- tempState ->CurrentBero ,
5478
+ state ->CurrentBero ,
5513
5479
ttyd::seq_mapchange::NextBero,
5514
- sizeof (tempState->CurrentBero ));
5480
+ sizeof (state->CurrentBero ));
5481
+ }
5482
+
5483
+ char *createCustomState ()
5484
+ {
5485
+ uint32_t tempTotalEntries = CustomState.TotalEntries ;
5486
+ CustomStateStruct *tempState = CustomState.State ;
5487
+
5488
+ if (tempTotalEntries == 0 )
5489
+ {
5490
+ // No custom states exist, so create one
5491
+ if (tempState)
5492
+ {
5493
+ delete[] (tempState);
5494
+ }
5495
+
5496
+ tempState = new CustomStateStruct;
5497
+ CustomState.State = tempState;
5498
+
5499
+ tempTotalEntries = 1 ;
5500
+ CustomState.TotalEntries = tempTotalEntries;
5501
+ }
5502
+ else if (tempTotalEntries >= CUSTOM_STATES_MAX_COUNT)
5503
+ {
5504
+ // Maximum number of states have been made
5505
+ return nullptr ;
5506
+ }
5507
+ else
5508
+ {
5509
+ tempState = resizeStateMemory (tempState, tempTotalEntries, 1 );
5510
+ CustomState.State = tempState;
5511
+
5512
+ tempTotalEntries++;
5513
+ CustomState.TotalEntries = tempTotalEntries;
5514
+ }
5515
+
5516
+ tempState = &tempState[tempTotalEntries - 1 ];
5517
+ setCustomStateData (tempState);
5515
5518
5516
5519
// Return a pointer to the new state's name
5517
5520
return tempState->StateName ;
0 commit comments