Char contacts convert & import

This commit is contained in:
sShemet
2026-02-04 20:45:21 +05:00
parent f3c41f2781
commit c2c36afc42
3 changed files with 48 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ Imports System.Net.Mime.MediaTypeNames
Imports System.Runtime.Remoting.Metadata.W3cXsd2001
Imports System.Text
Imports MadMilkman.Ini
Imports System.Linq.Expressions
Public Class Form1
@@ -658,7 +659,7 @@ Public Class Form1
filnam = EngISOPath.Text
ElseIf UserRadio.Checked Then
filnam = UserPath.Text
ElseIf KUDOSbtn.Checked Then
ElseIf KudosBtn.Checked Then
filnam = KUDOSpath.Text
ElseIf CDExtraBtn.Checked Then
filnam = CDEXTRApath.Text
@@ -847,7 +848,7 @@ Public Class Form1
For Each JFile In OpenFileDialog1.FileNames
Debug.WriteLine("Converting " & JFile)
txt.importContactFile(JFile, DialogCounter, LineCounter)
txt.ConvertTXT_To_Contact(JFile, DialogCounter, LineCounter)
Next
MsgBox("Success! Converted " & UBound(OpenFileDialog1.FileNames) + 1 & " file(s)" & vbCrLf & "Overall Dialogs Count: " & DialogCounter &
@@ -927,9 +928,9 @@ newtest:
'Try
Dim bytes() = SoapHexBinary.Parse(line).Value
If bytes.Length = 0 Then Exit Sub
If bytes.Length = 0 Then Exit Sub
text.DrawChars(bytes.ToList, drawSurface, y, curColor)
text.DrawChars(bytes.ToList, drawSurface, y, curColor)
'Catch ex As Exception
'MsgBox("Error in codes!")
'End Try
@@ -1151,7 +1152,7 @@ rleEnd:
Next
'dungeons & summon text & battle contacts
If CDFileList.SelectedIndex = 735 Or CDFileList.SelectedIndex = 35 Or CDFileList.SelectedIndex = 1075 Then
If CDFileList.SelectedIndex = 735 Or CDFileList.SelectedIndex = 35 Or CDFileList.SelectedIndex = 863 Then
'checking crazy last 20 bytes on sector for file IN SUUMON AND DUNGEON TEXTS
Dim ffff = 2048 - (finalPack.Count Mod 2048)
If ffff <= 20 And ffff > 0 Then
@@ -1215,8 +1216,8 @@ rleEnd:
Update0032SummonScriptTable(addresses) 'summon scripts table in 0032 & 33. Summon and mutation code
'Case 1075
' UpdateBattleContactFileTable(addresses) 'Updating BattleContacts
Case 863
UpdateCharContactFileTable(addresses) 'Updating Char contact
End Select
@@ -1250,7 +1251,34 @@ rleEnd:
'Done
MsgBox(String.Format("Imported {0} files in {1} - {2} bytes", UBound(OpenFileDialog1.FileNames) + 1, CDFileList.SelectedIndex, finalPack.Count), MsgBoxStyle.Exclamation)
End Sub
Public Sub UpdateCharContactFileTable(ByRef addr As List(Of Integer))
Dim cd = New ISOTools
Dim codeFile = cd.getCDfile(UserPath.Text, files1(789).Sector, files1(789).Sizw).ToArray() 'Battle Code
Dim TableOffset = 305548
Dim curElement = 0
For a = 0 To addr.Count - 1
Dim curAddr = curElement * 4 + TableOffset
Dim value = BitConverter.ToUInt32(codeFile, curAddr)
Dim origOffset = value And &H7FF
Dim origSectors = (value And &H1FFFFFF) >> &HB
Dim origFilePack = value >> &H19
Dim fileSectorOffset As UInt32 = addr(a) \ 2048
Dim sectorByteOffset As UInt32 = addr(a) Mod 2048
Dim finalValue As UInt32 = (origFilePack << &H19) Or (fileSectorOffset << &HB) Or sectorByteOffset
Dim bytes = BitConverter.GetBytes(finalValue)
Buffer.BlockCopy(bytes, 0, codeFile, curAddr, 4)
curElement += 1
a = a + origFilePack - 1
Next
cd.saveCDfile(UserPath.Text, files1(789).Sector, files1(789).Sizw, codeFile)
End Sub
Public Sub UpdateBattleContactFileTable(ByRef addr As List(Of Integer))
Dim cd = New ISOTools