Skip to content

Commit

Permalink
added hex string property to fguid
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianFG committed Nov 21, 2019
1 parent a834c48 commit 73f6237
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
32 changes: 25 additions & 7 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group "me.fungames"
version "2.1.2"
version "2.1.3"

repositories {
mavenCentral()
Expand Down
32 changes: 27 additions & 5 deletions src/main/kotlin/me/fungames/jfortniteparse/ue4/UE Classes.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
}

Expand All @@ -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
Expand Down Expand Up @@ -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()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 73f6237

Please sign in to comment.