mirror of
https://github.com/P3D-Legacy/P3D-Legacy.git
synced 2025-07-29 00:34:38 +02:00
Prevent crash when no Data\Contacts.dat
This commit is contained in:
parent
d516a1e152
commit
3bd6f1af5b
@ -1420,26 +1420,27 @@
|
|||||||
|
|
||||||
Private Sub InitializePhone()
|
Private Sub InitializePhone()
|
||||||
InitializedPhone = True
|
InitializedPhone = True
|
||||||
|
If System.IO.File.Exists(GameModeManager.GetContentFilePath("Data\contacts.dat")) Then
|
||||||
|
Dim reg() As String = Core.Player.RegisterData.Split(CChar(","))
|
||||||
|
|
||||||
Dim reg() As String = Core.Player.RegisterData.Split(CChar(","))
|
Dim contactData() As String = System.IO.File.ReadAllLines(GameModeManager.GetContentFilePath("Data\contacts.dat"))
|
||||||
|
|
||||||
Dim contactData() As String = System.IO.File.ReadAllLines(GameModeManager.GetContentFilePath("Data\contacts.dat"))
|
For Each r As String In reg
|
||||||
|
If r.StartsWith("phone_contact_") = True Then
|
||||||
|
Dim newID As String = r.Remove(0, "phone_contact_".Length)
|
||||||
|
|
||||||
For Each r As String In reg
|
For Each line As String In contactData
|
||||||
If r.StartsWith("phone_contact_") = True Then
|
If line.StartsWith(newID & "|") = True Then
|
||||||
Dim newID As String = r.Remove(0, "phone_contact_".Length)
|
Dim NCD() As String = line.Split(CChar("|"))
|
||||||
|
|
||||||
For Each line As String In contactData
|
Dim newContact As New Contact With {.ID = NCD(0), .Name = NCD(1), .Texture = NCD(2), .Location = NCD(3), .CanRandomCall = CBool(NCD(4))}
|
||||||
If line.StartsWith(newID & "|") = True Then
|
|
||||||
Dim NCD() As String = line.Split(CChar("|"))
|
|
||||||
|
|
||||||
Dim newContact As New Contact With {.ID = NCD(0), .Name = NCD(1), .Texture = NCD(2), .Location = NCD(3), .CanRandomCall = CBool(NCD(4))}
|
PhoneContacts.Add(newContact)
|
||||||
|
End If
|
||||||
PhoneContacts.Add(newContact)
|
Next
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
Next
|
|
||||||
|
|
||||||
PhoneContacts = (From c In PhoneContacts Order By c.ID Ascending).ToList()
|
PhoneContacts = (From c In PhoneContacts Order By c.ID Ascending).ToList()
|
||||||
End Sub
|
End Sub
|
||||||
@ -1507,6 +1508,9 @@
|
|||||||
If Core.CurrentScreen.Identification <> Identifications.OverworldScreen Then
|
If Core.CurrentScreen.Identification <> Identifications.OverworldScreen Then
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
If System.IO.File.Exists(GameModeManager.GetContentFilePath("Data\contacts.dat")) = False Then
|
||||||
|
Exit Sub
|
||||||
|
End If
|
||||||
|
|
||||||
Dim reg() As String = Core.Player.RegisterData.Split(CChar(","))
|
Dim reg() As String = Core.Player.RegisterData.Split(CChar(","))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user