@@ -590,13 +590,21 @@ private static void _GCCollect() {
590590 public override void End ( ) {
591591 orig_End ( ) ;
592592
593- // reload the vanilla Portraits.xml in case it was overridden by a map
594- // else, if the Portraits.xml doesn't have portrait_madeline defined,
595- // the game will crash when trying to load a save file (since it shows madeline's portrait)
596- GFX . PortraitsSpriteBank = new SpriteBank ( GFX . Portraits , Path . Combine ( "Graphics" , "Portraits.xml" ) ) ;
593+ Scene nextScene = patch_Engine . NextScene ;
594+
595+ // reload the vanilla Portraits.xml when exiting; if a map overrides the Portraits.xml
596+ // and doesn't have portrait_madeline defined, the game would crash when trying to load a save file
597+ // (since it shows madeline's portrait)
598+ //
599+ // however we need to pay attention to the new scene, else we'll reload vanilla portraits too soon
600+ // and make custom portraits stop working. therefore, we ignore these scenes as they don't actually
601+ // exit the map
602+ if ( nextScene is not ( LevelLoader or Pico8 . Emulator or OverworldReflectionsFall ) ) {
603+ GFX . PortraitsSpriteBank = new SpriteBank ( GFX . Portraits , Path . Combine ( "Graphics" , "Portraits.xml" ) ) ;
604+ }
597605
598606 // if we are not entering PICO-8 or the Reflection Fall cutscene...
599- if ( patch_Engine . NextScene is not ( Pico8 . Emulator or OverworldReflectionsFall ) ) {
607+ if ( nextScene is not ( Pico8 . Emulator or OverworldReflectionsFall ) ) {
600608 // break all links between this level and its entities.
601609 foreach ( Entity entity in Entities ) {
602610 ( ( patch_Entity ) entity ) . DissociateFromScene ( ) ;
0 commit comments