@@ -476,18 +476,18 @@ bool Mod::performRelPatches(gc::OSModule::OSModuleInfo *newModule, void *bss)
476
476
}
477
477
}
478
478
479
- void addTextToHeapArray (char *text)
479
+ void addTextToHeapBuffer (char *text)
480
480
{
481
481
char *tempHeapBuffer = HeapBuffer;
482
482
483
483
// Make sure adding the new text will not result in an overflow
484
484
uint32_t NewTextSize = strlen (text);
485
- uint32_t CurrentHeapSize = strlen (tempHeapBuffer);
485
+ uint32_t CurrentHeapBufferSize = strlen (tempHeapBuffer);
486
486
487
- uint32_t NewHeapSize = CurrentHeapSize + NewTextSize + 1 ;
488
- uint32_t MaxHeapSize = sizeof (HeapBuffer);
487
+ uint32_t NewHeapBufferSize = CurrentHeapBufferSize + NewTextSize + 1 ;
488
+ uint32_t MaxHeapBufferSize = sizeof (HeapBuffer);
489
489
490
- if (NewHeapSize > MaxHeapSize )
490
+ if (NewHeapBufferSize > MaxHeapBufferSize )
491
491
{
492
492
// Adding the new text will result in an overflow, so don't add it
493
493
return ;
@@ -582,7 +582,7 @@ void checkHeaps()
582
582
currentChunk);
583
583
584
584
// Add the text to the heap buffer
585
- addTextToHeapArray (tempDisplayBuffer);
585
+ addTextToHeapBuffer (tempDisplayBuffer);
586
586
}
587
587
588
588
// Check the free entries
@@ -595,7 +595,7 @@ void checkHeaps()
595
595
currentChunk);
596
596
597
597
// Add the text to the heap buffer
598
- addTextToHeapArray (tempDisplayBuffer);
598
+ addTextToHeapBuffer (tempDisplayBuffer);
599
599
}
600
600
}
601
601
@@ -611,7 +611,7 @@ void checkHeaps()
611
611
currentChunk);
612
612
613
613
// Add the text to the heap buffer
614
- addTextToHeapArray (tempDisplayBuffer);
614
+ addTextToHeapBuffer (tempDisplayBuffer);
615
615
}
616
616
617
617
// Check the free entries
@@ -623,7 +623,7 @@ void checkHeaps()
623
623
currentChunk);
624
624
625
625
// Add the text to the heap buffer
626
- addTextToHeapArray (tempDisplayBuffer);
626
+ addTextToHeapBuffer (tempDisplayBuffer);
627
627
}
628
628
629
629
// Draw any errors that occured
@@ -633,6 +633,55 @@ void checkHeaps()
633
633
}
634
634
}
635
635
636
+ ttyd::npcdrv::NpcEntry *Mod::npcNameToPtr_New (const char *name)
637
+ {
638
+ // Get the work pointer
639
+ ttyd::npcdrv::NpcWork *NpcWorkPointer = ttyd::npcdrv::npcGetWorkPtr ();
640
+
641
+ // Loop through the NPCs to find the correct one
642
+ ttyd::npcdrv::NpcEntry *NPC = nullptr ;
643
+ uint32_t MaxNpcCount = NpcWorkPointer->npcMaxCount ;
644
+
645
+ for (uint32_t i = 0 ; i < MaxNpcCount; i++)
646
+ {
647
+ NPC = &NpcWorkPointer->entries [i];
648
+ if (NPC->flags & (1 << 0 )) // Check if 0 bit is active
649
+ {
650
+ if (compareStrings (NPC->wUnkAnimation , name))
651
+ {
652
+ return NPC;
653
+ }
654
+ }
655
+ }
656
+
657
+ // Didn't find the correct NPC, so return the last one and print error text
658
+ // Only print the error text if currently not printing any previous error text
659
+ if (NpcNameToPtrError.Timer == 0 )
660
+ {
661
+ const char *Text = " npcNameToPtr error occured" ;
662
+ strcpy (NpcNameToPtrError.Buffer , Text);
663
+ NpcNameToPtrError.Timer = secondsToFrames (5 );
664
+ }
665
+
666
+ return NPC;
667
+ }
668
+
669
+ void displayNpcNameToPtrError ()
670
+ {
671
+ uint32_t Timer = NpcNameToPtrError.Timer ;
672
+ if (Timer > 0 )
673
+ {
674
+ Timer--;
675
+ NpcNameToPtrError.Timer = Timer;
676
+ }
677
+
678
+ // Call the drawing function regardless of the current time, as the drawing function is what clears the buffer
679
+ if (NpcNameToPtrError.Buffer [0 ] != ' \0 ' )
680
+ {
681
+ drawFunctionOnDebugLayerWithOrder (drawNpcNameToPtrError, 100 .f );
682
+ }
683
+ }
684
+
636
685
void initAddressOverwrites ()
637
686
{
638
687
#ifdef TTYD_US
@@ -818,6 +867,7 @@ void Mod::run()
818
867
displayMarioSpeedXZ ();
819
868
displayStickAngle ();
820
869
displayMemoryWatches ();
870
+ displayNpcNameToPtrError ();
821
871
}
822
872
823
873
// Only run button-based displays if currently not changing button combos
0 commit comments