diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d1a4b6c..1b97669 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,10 +1,11 @@ - + + - + - + @@ -240,7 +241,11 @@ - + + + + + 1572648237801 @@ -326,7 +331,14 @@ - @@ -360,7 +372,8 @@ - @@ -381,7 +394,7 @@ file://$PROJECT_DIR$/src/test/kotlin/Test.kt - 45 + 47 @@ -389,6 +402,11 @@ 106 + + file://$PROJECT_DIR$/src/test/kotlin/Test.kt + 23 + diff --git a/build.gradle b/build.gradle index d826b12..f41f130 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group "me.fungames" -version "2.1.2" +version "2.1.3" repositories { mavenCentral() diff --git a/src/main/kotlin/me/fungames/jfortniteparse/ue4/UE Classes.kt b/src/main/kotlin/me/fungames/jfortniteparse/ue4/UE Classes.kt index c6c9145..593a0e9 100644 --- a/src/main/kotlin/me/fungames/jfortniteparse/ue4/UE Classes.kt +++ b/src/main/kotlin/me/fungames/jfortniteparse/ue4/UE Classes.kt @@ -1,8 +1,12 @@ package me.fungames.jfortniteparse.ue4 +import me.fungames.jfortniteparse.ue4.assets.writer.FByteArrayArchiveWriter import me.fungames.jfortniteparse.ue4.pak.reader.FPakArchive import me.fungames.jfortniteparse.ue4.reader.FArchive +import me.fungames.jfortniteparse.ue4.reader.FByteArchive import me.fungames.jfortniteparse.ue4.writer.FArchiveWriter +import me.fungames.jfortniteparse.util.parseHexBinary +import me.fungames.jfortniteparse.util.printHexBinary import mu.KotlinLogging @ExperimentalUnsignedTypes @@ -60,13 +64,16 @@ class FGuid : UEClass { var part2: UInt var part3: UInt var part4: UInt + var hexString : String constructor(Ar: FArchive) { super.init(Ar) - part1 = Ar.readUInt32() - part2 = Ar.readUInt32() - part3 = Ar.readUInt32() - part4 = Ar.readUInt32() + val ar = FByteArchive(Ar.read(16)) + part1 = ar.readUInt32() + part2 = ar.readUInt32() + part3 = ar.readUInt32() + part4 = ar.readUInt32() + hexString = ar.data.printHexBinary() super.complete(Ar) } @@ -78,7 +85,7 @@ class FGuid : UEClass { Ar.writeUInt32(part4) super.completeWrite(Ar) } - + override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false @@ -107,6 +114,21 @@ class FGuid : UEClass { this.part2 = part2 this.part3 = part3 this.part4 = part4 + val ar = FByteArrayArchiveWriter() + ar.writeUInt32(part1) + ar.writeUInt32(part2) + ar.writeUInt32(part3) + ar.writeUInt32(part4) + this.hexString = ar.toByteArray().printHexBinary() + } + + constructor(hexString : String) { + this.hexString = hexString + val ar = FByteArchive(hexString.parseHexBinary()) + part1 = ar.readUInt32() + part2 = ar.readUInt32() + part3 = ar.readUInt32() + part4 = ar.readUInt32() } /** diff --git a/src/main/kotlin/me/fungames/jfortniteparse/util/DataTypeConverter.kt b/src/main/kotlin/me/fungames/jfortniteparse/util/DataTypeConverter.kt index afd9074..e1289ed 100644 --- a/src/main/kotlin/me/fungames/jfortniteparse/util/DataTypeConverter.kt +++ b/src/main/kotlin/me/fungames/jfortniteparse/util/DataTypeConverter.kt @@ -21,6 +21,17 @@ fun String.parseHexBinary(): ByteArray { return out } +private val hexCode = "0123456789ABCDEF".toCharArray() + +fun ByteArray.printHexBinary() : String { + val r = StringBuilder(size * 2) + for (b in this) { + r.append(hexCode[b.toInt() shr 4 and 0xF]) + r.append(hexCode[b.toInt() and 0xF]) + } + return r.toString() +} + private fun hexToBin(ch: Char): Int { if (ch in '0'..'9') { return ch - '0'