Skip to content

Commit c323985

Browse files
committed
Bump version, fix for Immortal Pillars
Fix one command type, start debugging xmb Bump version to v0.3.0 and fix for Immortal Pillars add comment
1 parent ee537e9 commit c323985

File tree

8 files changed

+27
-7
lines changed

8 files changed

+27
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ restoration
33
releases/
44
test.json
55
.idea
6+
decompressed.hex

parser/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package parser
33
const MAX_SCAN_OFFSET = 50
44
const DATA_OFFSET = 6
55
const ROOT_NODE_TOKEN = "BG"
6-
const VERSION = "v0.2.4"
6+
const VERSION = "v0.3.0"
77

88
var FOOTER = []uint8{0, 1, 0, 0, 0, 0, 0, 0}
99

parser/gameCommandParser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ func parseGameCommand(data *[]byte, offset int, lastCommandListIdx int) (RawGame
222222
*/
223223
derefedData := *data
224224
commandType := int(derefedData[offset+1])
225-
// slog.Debug(fmt.Sprintf("Parsing game command with type=%v at offset=%v", commandType, offset))
226225
tenBytesOffset := offset
227226
offset += 10
228227
if commandType == 14 {
@@ -293,6 +292,7 @@ func parseGameCommand(data *[]byte, offset int, lastCommandListIdx int) (RawGame
293292
&sourceVectors,
294293
&preArgumentBytes,
295294
)
295+
//slog.Debug(fmt.Sprintf("Parsing game command with type=%v at offset=%v", commandType, strconv.FormatInt(int64(offset), 16)))
296296
gameCommand := refiner(&baseCmd, data)
297297
offset += gameCommand.ByteLength()
298298

parser/gameCommands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ type FinishUnitTransformCommand struct {
602602
}
603603

604604
func (cmd FinishUnitTransformCommand) Refine(baseCommand *BaseCommand, data *[]byte) RawGameCommand {
605-
inputTypes := []func() int{unpackInt32, unpackInt32, unpackInt32, unpackInt8, unpackInt8}
605+
inputTypes := []func() int{unpackInt32, unpackInt32, unpackInt32, unpackInt32, unpackInt8, unpackInt8}
606606
byteLength := 0
607607
for _, f := range inputTypes {
608608
byteLength += f()

parser/header.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,18 @@ func areBytesValidTokens(bytes ...byte) bool {
112112
Determine whether any byte sequence is a valid Node token. Although there are no restrictions
113113
on this function, a valid token must only be two bytes.
114114
*/
115+
if len(bytes) != 2 {
116+
return false
117+
}
118+
119+
// For now, we are skipping the values "kL" as that is not a valid node, but it now appears directly after the
120+
// BG => GM => GD node, which was breaking the XMB parsing logic.
121+
// TODO: Figure out what kL actually is, probably some data identifier, showcasing data length or something like
122+
// that.
123+
if bytes[0] == 107 && bytes[1] == 76 {
124+
slog.Debug("Skipping token kL")
125+
return false
126+
}
115127
allValid := true
116128
for _, b := range bytes {
117129
allValid = allValid && validAlphaNumericAscii(b)

parser/parser.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func Parse(replayPath string, slim bool, stats bool, isGzip bool) (ReplayFormatt
5454
if err != nil {
5555
return ReplayFormatted{}, err
5656
}
57-
// saveHex(&data, "decompressed.hex")
57+
//saveHex(&data, "decompressed.hex")
5858

5959
rootNode := parseHeader(&data)
6060

@@ -74,12 +74,16 @@ func Parse(replayPath string, slim bool, stats bool, isGzip bool) (ReplayFormatt
7474
return ReplayFormatted{}, err
7575
}
7676
//printProfileKeys(profileKeys)
77-
// techtreerootnode, err := parseXmb(&data, xmbMap["techtree"])
77+
// for key, _ := range xmbMap {
78+
// fmt.Println("==========================")
79+
// fmt.Println(key)
80+
// }
81+
// techtreerootnode, err := parseXmb(&data, xmbMap["protounitcommands"])
7882
// if err != nil {
7983
// return ReplayFormatted{}, err
8084
// }
8185
// for _, child := range techtreerootnode.children {
82-
// fmt.Println(child.attributes["name"])
86+
// fmt.Println(child)
8387
// }
8488

8589
svBytes := bytes.Index(raw_data, []byte{0x73, 0x76}) // search for index of the "sv" bytes

parser/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (err FooterNotFoundError) Error() string {
118118
type UnkNotEqualTo1Error int
119119

120120
func (err UnkNotEqualTo1Error) Error() string {
121-
return fmt.Sprintf("The unknown byte in footer search did not equal 1 at offset %v", int(err))
121+
return fmt.Sprintf("The unknown byte in footer search did not equal 1 at offset %v", strconv.FormatInt(int64(err), 16))
122122
}
123123

124124
// ===============================

parser/xmb.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ func parseXmbMap(data *[]byte, rootNode Node) (map[string]XmbFile, error) {
2525
if numFiles > 1 {
2626
// Read two strings, keep the second as xmbName
2727
str1 := readString(data, offset)
28+
// slog.Debug("String 1", "str1", str1.value)
2829
xmbName = readString(data, str1.endOffset)
30+
// slog.Debug("String 2", "xmbName", xmbName.value)
2931
offset = xmbName.endOffset
3032
} else {
3133
// If there is only one XMB file, it is stored 20 bytes after the start of the node
@@ -44,6 +46,7 @@ func parseXmbMap(data *[]byte, rootNode Node) (map[string]XmbFile, error) {
4446
}
4547

4648
func parseXmb(data *[]byte, xmbFile XmbFile) (XmbNode, error) {
49+
slog.Debug("Parsing XMB file", "xmbFile", xmbFile.name)
4750
offset := xmbFile.offset
4851
x1 := readUint16(data, offset)
4952
if x1 != 12632 {

0 commit comments

Comments
 (0)