Properly fix the BattleAnim Memory Leak now...

I didn't do it right the first time lol
This commit is contained in:
JappaWakka 2025-03-17 17:48:54 +01:00
parent 3b298ba2b5
commit fe6098fc7b

View File

@ -88,6 +88,9 @@
Public Shared BattleMapOffset As New Vector3(0) Public Shared BattleMapOffset As New Vector3(0)
Public BackgroundTarget As RenderTarget2D
Public NPCTarget As RenderTarget2D
Public Overrides Function GetScreenStatus() As String Public Overrides Function GetScreenStatus() As String
Dim pokemonString As String = "OwnPokemon=OWNEMPTY" & Environment.NewLine & Dim pokemonString As String = "OwnPokemon=OWNEMPTY" & Environment.NewLine &
"OppPokemon=OPPEMPTY" "OppPokemon=OPPEMPTY"
@ -177,6 +180,10 @@
Me.BattleMenu = New BattleMenu() Me.BattleMenu = New BattleMenu()
BattleMenu.Reset() BattleMenu.Reset()
BackgroundTarget = New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
NPCTarget = New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
End Sub End Sub
Public Sub InitializeWild(ByVal WildPokemon As Pokemon, ByVal OverworldScreen As Screen, ByVal defaultMapType As Integer) Public Sub InitializeWild(ByVal WildPokemon As Pokemon, ByVal OverworldScreen As Screen, ByVal defaultMapType As Integer)
@ -1019,7 +1026,6 @@ nextIndexBackground:
cQuery.Reverse() cQuery.Reverse()
Dim BackgroundTarget As New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
Core.GraphicsDevice.SetRenderTarget(BackgroundTarget) Core.GraphicsDevice.SetRenderTarget(BackgroundTarget)
GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Transparent) GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Transparent)
@ -1028,8 +1034,6 @@ nextIndexBackground:
Next Next
Core.GraphicsDevice.SetRenderTarget(Nothing) Core.GraphicsDevice.SetRenderTarget(Nothing)
Dim NPCTarget As New RenderTarget2D(Core.GraphicsDevice, Core.windowSize.Width, Core.windowSize.Height, False, SurfaceFormat.Color, DepthFormat.Depth24Stencil8)
Core.GraphicsDevice.SetRenderTarget(NPCTarget) Core.GraphicsDevice.SetRenderTarget(NPCTarget)
GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Transparent) GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.Transparent)
For i = 0 To ForegroundEntities.Count - 1 For i = 0 To ForegroundEntities.Count - 1
@ -1047,8 +1051,6 @@ nextIndexBackground:
World.DrawWeather(Screen.Level.World.CurrentMapWeather) World.DrawWeather(Screen.Level.World.CurrentMapWeather)
Core.SpriteBatch.Draw(BackgroundTarget, windowSize, Color.White) Core.SpriteBatch.Draw(BackgroundTarget, windowSize, Color.White)
Core.SpriteBatch.Draw(NPCTarget, windowSize, Color.White) Core.SpriteBatch.Draw(NPCTarget, windowSize, Color.White)
NPCTarget.Dispose()
BackgroundTarget.Dispose()
Else Else
SkyDome.Draw(45.0F) SkyDome.Draw(45.0F)
Level.Draw() Level.Draw()
@ -1531,6 +1533,9 @@ nextIndex:
BattleMapOffset = New Vector3(0) BattleMapOffset = New Vector3(0)
OwnLeadIndex = 0 OwnLeadIndex = 0
OppLeadIndex = 0 OppLeadIndex = 0
BackgroundTarget.Dispose()
NPCTarget.Dispose()
End Sub End Sub
Public Sub ChangeSavedScreen() Public Sub ChangeSavedScreen()