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

View File

@ -11,14 +11,14 @@ Public Class RoamingPokemon
Dim data() As String = DataLine.Split(CChar("|")) Dim data() As String = DataLine.Split(CChar("|"))
Me.RoamerID = data(0) Me.RoamerID = data(0)
Me.PokemonReference = Pokemon.GetPokemonByData(data(6)) Me.PokemonReference = Pokemon.GetPokemonByData(data(8))
Me.WorldID = CInt(data(3)) Me.WorldID = CInt(data(3))
Me.LevelFile = data(4) Me.LevelFile = data(4)
Me.MusicLoop = data(5) Me.MusicLoop = data(5)
If data.Length = 9 Then If data.Length = 10 Then
ScriptPath = data(8) ScriptPath = data(9)
End If End If
End Sub End Sub
@ -35,7 +35,7 @@ Public Class RoamingPokemon
Dim newData As String = "" Dim newData As String = ""
For Each line As String In Core.Player.RoamingPokemonData.SplitAtNewline() 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("|")) Dim data() As String = line.Split(CChar("|"))
If newData <> "" Then If newData <> "" Then
@ -88,12 +88,7 @@ Public Class RoamingPokemon
Dim newData As String = "" Dim newData As String = ""
For Each line As String In Core.Player.RoamingPokemonData.SplitAtNewline() 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 line.StartsWith(compareData) = False Then
If newData <> "" Then
newData &= Environment.NewLine
End If
newData &= line
ElseIf line.StartsWith(compareData) = False Then
If newData <> "" Then If newData <> "" Then
newData &= Environment.NewLine newData &= Environment.NewLine
End If End If
@ -114,9 +109,7 @@ Public Class RoamingPokemon
newData &= Environment.NewLine newData &= Environment.NewLine
End If End If
If line.CountSeperators("|") = 7 AndAlso line.StartsWith(compareData.Remove(0, compareData.IndexOf("|") + 1)) = False Then If line.StartsWith(compareData) = False Then
newData &= line
ElseIf line.StartsWith(compareData) = False Then
newData &= line newData &= line
Else 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 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) Dim roamingPokemon As RoamingPokemon = CheckForRoaming(LevelFile, Method)
If Not roamingPokemon Is Nothing Then 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.RoamingBattle = True
BattleSystem.BattleScreen.RoamingPokemonStorage = roamingPokemon BattleSystem.BattleScreen.RoamingPokemonStorage = roamingPokemon
Return roamingPokemon.GetPokemon() Return roamingPokemon.GetPokemon()
@ -111,8 +111,6 @@ Public Class Spawner
If cLine <> "" Then If cLine <> "" Then
If cLine.CountSeperators("|") >= 8 Then If cLine.CountSeperators("|") >= 8 Then
possibleEncounters.Add(cLine) possibleEncounters.Add(cLine)
ElseIf cLine.CountSeperators("|") = 7 Then
possibleEncounters.Add(Random.Next(100, 1001).ToString & "|" & cLine)
End If End If
End If End If
Next Next

View File

@ -316,15 +316,26 @@
If Not String.IsNullOrWhiteSpace(Core.Player.RoamingPokemonData) Then If Not String.IsNullOrWhiteSpace(Core.Player.RoamingPokemonData) Then
If Core.Player.RoamingPokemonData.Length > 0 AndAlso Core.Player.RoamingPokemonData.Contains("|") Then If Core.Player.RoamingPokemonData.Length > 0 AndAlso Core.Player.RoamingPokemonData.Contains("|") Then
For Each Pokes As String In Core.Player.RoamingPokemonData.SplitAtNewline 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 TempData() As String = Pokes.Split("|")
Dim MapFiles() As String = Tags("mapfiles").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 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 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 End If
Next Next
End If End If
@ -1370,7 +1381,7 @@
Public Class Roaming Public Class Roaming
Public ID As Integer Public ID As String
Public Name As String Public Name As String
Public Location As String Public Location As String
Public PositionX As Integer Public PositionX As Integer
@ -1380,10 +1391,20 @@
Dim T As Texture2D = Nothing 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.ID = ID
Me.Name = Pokemon.GetPokemonByID(ID).GetName Dim PokemonID As String = ID
Me.Species = Pokemon.GetPokemonByID(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.PositionX = PositionX
Me.PositionY = PositionY Me.PositionY = PositionY
Me.Location = Location Me.Location = Location

View File

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