Fix some roamer bugs and crashes

This commit is contained in:
JappaWakka 2024-04-04 18:36:36 +02:00
parent 65ec57d27b
commit 62f6605a0f
5 changed files with 52 additions and 38 deletions

View File

@ -974,23 +974,25 @@
If RoamingPokemonData <> "" Then
RoamingPokemonData &= Environment.NewLine
End If
If line.CountSeperators("|") < 5 Then
If line.CountSeperators("|") < 6 Then
'Convert potential old data:
Dim data() As String = line.Split(CChar("|"))
Dim newP As Pokemon = Pokemon.GetPokemonByID(CInt(data(0)))
newP.Generate(CInt(data(1)), True)
RoamingPokemonData &= newP.Number.ToString() & "|" & newP.Level.ToString() & "|" & data(2) & "|" & data(3) & "||" & newP.IsShiny.ToNumberString() & "|" & newP.GetSaveData()
Else
If line.CountSeperators("|") < 6 Then
'Update to include shiny
Dim data() As String = line.Split(CChar("|"))
Dim newP As Pokemon = Pokemon.GetPokemonByData(data(5))
RoamingPokemonData &= Random.Next(100, 1001).ToString & "|" & newP.Number.ToString() & "|" & newP.Level.ToString() & "|" & data(2) & "|" & data(3) & "||" & newP.IsShiny.ToNumberString() & "|" & newP.GetSaveData()
ElseIf line.CountSeperators("|") < 7 Then
'Update to include shiny (and identifier)
Dim data() As String = line.Split(CChar("|"))
Dim newP As Pokemon = Pokemon.GetPokemonByData(data(5))
RoamingPokemonData &= data(0) & "|" & data(1) & "|" & data(2) & "|" & data(3) & "|" & data(4) & "|" & newP.IsShiny.ToNumberString() & "|" & data(5)
Else
RoamingPokemonData &= line
End If
RoamingPokemonData &= Random.Next(100, 1001).ToString & "|" & data(0) & "|" & data(1) & "|" & data(2) & "|" & data(3) & "|" & data(4) & "|" & newP.IsShiny.ToNumberString() & "|" & data(5)
ElseIf line.CountSeperators("|") < 8 Then
'Update to include (and identifier)
Dim data() As String = line.Split(CChar("|"))
RoamingPokemonData &= Random.Next(100, 1001).ToString & "|" & data(0) & "|" & data(1) & "|" & data(2) & "|" & data(3) & "|" & data(4) & "|" & "|" & data(5) & "|" & data(6)
Else
RoamingPokemonData &= line
End If
Next
End If

View File

@ -11,14 +11,14 @@ Public Class RoamingPokemon
Dim data() As String = DataLine.Split(CChar("|"))
Me.RoamerID = data(0)
Me.PokemonReference = Pokemon.GetPokemonByData(data(6))
Me.PokemonReference = Pokemon.GetPokemonByData(data(8))
Me.WorldID = CInt(data(3))
Me.LevelFile = data(4)
Me.MusicLoop = data(5)
If data.Length = 9 Then
ScriptPath = data(8)
If data.Length = 10 Then
ScriptPath = data(9)
End If
End Sub
@ -35,7 +35,7 @@ Public Class RoamingPokemon
Dim newData As String = ""
For Each line As String In Core.Player.RoamingPokemonData.SplitAtNewline()
If line <> "" And line.CountSeperators("|") >= 7 Then
If line <> "" AndAlso line.CountSeperators("|") >= 8 Then
Dim data() As String = line.Split(CChar("|"))
If newData <> "" Then
@ -88,12 +88,7 @@ Public Class RoamingPokemon
Dim newData As String = ""
For Each line As String In Core.Player.RoamingPokemonData.SplitAtNewline()
If line.CountSeperators("|") = 7 AndAlso line.StartsWith(compareData.Remove(0, compareData.IndexOf("|") + 1)) = False Then
If newData <> "" Then
newData &= Environment.NewLine
End If
newData &= line
ElseIf line.StartsWith(compareData) = False Then
If line.StartsWith(compareData) = False Then
If newData <> "" Then
newData &= Environment.NewLine
End If
@ -114,9 +109,7 @@ Public Class RoamingPokemon
newData &= Environment.NewLine
End If
If line.CountSeperators("|") = 7 AndAlso line.StartsWith(compareData.Remove(0, compareData.IndexOf("|") + 1)) = False Then
newData &= line
ElseIf line.StartsWith(compareData) = False Then
If line.StartsWith(compareData) = False Then
newData &= line
Else
newData &= p.RoamerID & "|" & p.PokemonReference.Number & "|" & p.PokemonReference.Level & "|" & p.WorldID.ToString() & "|" & p.LevelFile & "|" & p.MusicLoop & "|" & p.PokemonReference.IsShiny & "|" & p.PokemonReference.GetSaveData() & "|" & p.ScriptPath

View File

@ -24,7 +24,7 @@ Public Class Spawner
Dim roamingPokemon As RoamingPokemon = CheckForRoaming(LevelFile, Method)
If Not roamingPokemon Is Nothing Then
Logger.Debug("Roaming Pokemon (" & roamingPokemon.PokemonReference.Number & ") appears!")
Logger.Debug("Roaming Pokemon (" & PokemonForms.GetPokemonDataFileName(roamingPokemon.PokemonReference.Number, roamingPokemon.PokemonReference.AdditionalData, True) & ") appears!")
BattleSystem.BattleScreen.RoamingBattle = True
BattleSystem.BattleScreen.RoamingPokemonStorage = roamingPokemon
Return roamingPokemon.GetPokemon()
@ -111,8 +111,6 @@ Public Class Spawner
If cLine <> "" Then
If cLine.CountSeperators("|") >= 8 Then
possibleEncounters.Add(cLine)
ElseIf cLine.CountSeperators("|") = 7 Then
possibleEncounters.Add(Random.Next(100, 1001).ToString & "|" & cLine)
End If
End If
Next

View File

@ -316,15 +316,26 @@
If Not String.IsNullOrWhiteSpace(Core.Player.RoamingPokemonData) Then
If Core.Player.RoamingPokemonData.Length > 0 AndAlso Core.Player.RoamingPokemonData.Contains("|") Then
For Each Pokes As String In Core.Player.RoamingPokemonData.SplitAtNewline
' PokémonID,Level,regionID,startLevelFile,MusicLoop,Shiny,PokemonData
' RoamerID,PokémonID,Level,regionID,startLevelFile,MusicLoop,[Shiny],[ScriptPath]
Dim TempData() As String = Pokes.Split("|")
Dim MapFiles() As String = Tags("mapfiles").Split(",")
Dim PokeCurrentLocation As String = TempData(3)
Dim PokeCurrentLocation As String = TempData(4)
If MapFiles.Contains(PokeCurrentLocation) Then
TempPoke.Add(New Roaming(CInt(TempData(0)), CInt(Tags("position").Split(",")(0)), CInt(Tags("position").Split(",")(1)), Tags("name")))
TempPoke.Add(New Roaming(TempData(1), CInt(Tags("position").Split(",")(0)), CInt(Tags("position").Split(",")(1)), Tags("name")))
End If
If RoamingPokeName Is Nothing OrElse Not RoamingPokeName.Contains(Pokemon.GetPokemonByID(CInt(TempData(0))).GetName) Then
RoamingPokeName.Add(Pokemon.GetPokemonByID(CInt(TempData(0))).GetName)
Dim PokemonID As String = TempData(1)
Dim PokemonAddition As String = "xXx"
If PokemonID.Contains("_") Then
PokemonAddition = PokemonForms.GetAdditionalValueFromDataFile(TempData(1))
PokemonID = TempData(1).GetSplit(0, "_")
End If
If PokemonID.Contains(";") Then
PokemonAddition = TempData(1).GetSplit(1, ";")
PokemonID = TempData(1).GetSplit(0, ";")
End If
If RoamingPokeName Is Nothing OrElse Not RoamingPokeName.Contains(Pokemon.GetPokemonByID(CInt(PokemonID), PokemonAddition).GetName) Then
RoamingPokeName.Add(Pokemon.GetPokemonByID(CInt(PokemonID), PokemonAddition).GetName)
End If
Next
End If
@ -1370,7 +1381,7 @@
Public Class Roaming
Public ID As Integer
Public ID As String
Public Name As String
Public Location As String
Public PositionX As Integer
@ -1380,10 +1391,20 @@
Dim T As Texture2D = Nothing
Public Sub New(ByVal ID As Integer, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal Location As String)
Public Sub New(ByVal ID As String, ByVal PositionX As Integer, ByVal PositionY As Integer, ByVal Location As String)
Me.ID = ID
Me.Name = Pokemon.GetPokemonByID(ID).GetName
Me.Species = Pokemon.GetPokemonByID(ID)
Dim PokemonID As String = ID
Dim PokemonAddition As String = "xXx"
If PokemonID.Contains("_") Then
PokemonAddition = PokemonForms.GetAdditionalValueFromDataFile(ID)
PokemonID = ID.GetSplit(0, "_")
End If
If PokemonID.Contains(";") Then
PokemonAddition = ID.GetSplit(1, ";")
PokemonID = ID.GetSplit(0, ";")
End If
Me.Name = Pokemon.GetPokemonByID(CInt(PokemonID), PokemonAddition).GetName
Me.Species = Pokemon.GetPokemonByID(CInt(PokemonID), PokemonAddition)
Me.PositionX = PositionX
Me.PositionY = PositionY
Me.Location = Location

View File

@ -679,11 +679,11 @@
Dim PokemonID As String = data(1)
Dim PokemonAddition As String = "xXx"
If PokemonID.Contains("_") Then
PokemonAddition = PokemonForms.GetAdditionalValueFromDataFile(data(0))
PokemonAddition = PokemonForms.GetAdditionalValueFromDataFile(data(1))
PokemonID = data(1).GetSplit(0, "_")
End If
If PokemonID.Contains(";") Then
PokemonAddition = data(0).GetSplit(1, ";")
PokemonAddition = data(1).GetSplit(1, ";")
PokemonID = data(1).GetSplit(0, ";")
End If