-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for many native struct types
- Loading branch information
Showing
23 changed files
with
457 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package parser | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"strings" | ||
) | ||
|
||
type StructType struct { | ||
Type string `json:"type"` | ||
Value interface{} `json:"value"` | ||
} | ||
|
||
func (parser *PakParser) ReadStruct(property *StructProperty, size int32, depth int) (interface{}, bool) { | ||
switch strings.Trim(property.Type, "\x00") { | ||
case "Vector": | ||
return parser.ReadFVector(), true | ||
case "LinearColor": | ||
return parser.ReadFLinearColor(), true | ||
case "Vector2D": | ||
return parser.ReadFVector2D(), true | ||
case "IntPoint": | ||
return parser.ReadFIntPoint(), true | ||
case "Rotator": | ||
return parser.ReadFRotator(), true | ||
case "Quat": | ||
return parser.ReadFQuat(), true | ||
case "Vector4": | ||
return parser.ReadFVector4(), true | ||
case "Color": | ||
return parser.ReadFColor(), true | ||
case "Box": | ||
return parser.ReadFBox(), true | ||
case "FrameNumber": | ||
return parser.ReadFFrameNumber(), true | ||
case "MovieSceneSequenceID": | ||
return parser.ReadFMovieSceneSequenceID(), true | ||
case "Box2D": | ||
return parser.ReadFBox2D(), true | ||
case "MovieSceneTrackIdentifier": | ||
return parser.ReadFMovieSceneTrackIdentifier(), true | ||
case "MovieSceneEvaluationKey": | ||
return parser.ReadFMovieSceneEvaluationKey(), true | ||
case "MovieSceneSegmentIdentifier": | ||
return parser.ReadFMovieSceneSegmentIdentifier(), true | ||
case "MovieSceneFloatValue": | ||
return parser.ReadFMovieSceneFloatValue(), true | ||
case "RichCurveKey": | ||
return parser.ReadFRichCurveKey(), true | ||
case "MovieSceneFrameRange": | ||
return parser.ReadFMovieSceneFrameRange(), true | ||
case "Guid": | ||
if size == 16 { | ||
return parser.ReadFGuid(), true | ||
} | ||
|
||
// TODO Something is not right | ||
// return parser.ReadFGuid() | ||
fallthrough | ||
case "VectorMaterialInput": | ||
fallthrough | ||
case "ExpressionInput": | ||
fallthrough | ||
case "ScalarMaterialInput": | ||
fallthrough | ||
case "ColorMaterialInput": | ||
fallthrough | ||
case "PerPlatformFloat": | ||
fallthrough | ||
case "SkeletalMeshSamplingLODBuiltData": | ||
fallthrough | ||
case "PointerToUberGraphFrame": | ||
fallthrough | ||
case "FontData": | ||
fallthrough | ||
case "FontCharacter": | ||
fallthrough | ||
case "MaterialAttributesInput": | ||
fallthrough | ||
case "MovieSceneByteChannel": | ||
fallthrough | ||
case "MovieSceneEventParameters": | ||
fallthrough | ||
case "SoftClassPath": | ||
fallthrough | ||
case "MovieSceneParticleChannel": | ||
fallthrough | ||
case "InventoryItem": | ||
fallthrough | ||
case "SmartName": | ||
fallthrough | ||
case "PerPlatformInt": | ||
fallthrough | ||
case "MovieSceneSegment": | ||
fallthrough | ||
case "SectionEvaluationDataTree": | ||
fallthrough | ||
case "MovieSceneEvalTemplatePtr": | ||
fallthrough | ||
case "MovieSceneTrackImplementationPtr": | ||
fallthrough | ||
case "MovieSceneEvaluationTrack": | ||
fallthrough | ||
case "LevelSequenceBindingReferenceArray": | ||
// TODO Read types correctly | ||
log.Debugf("%sUnread StructProperty Type [%d]: %s", d(depth), size, strings.Trim(property.Type, "\x00")) | ||
// fmt.Println(utils.HexDump(data[offset:])) | ||
if size > 0 { | ||
parser.Read(size) | ||
} | ||
return nil, true | ||
default: | ||
// All others are fine | ||
break | ||
} | ||
|
||
return nil, false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package parser | ||
|
||
type FBox struct { | ||
IsValid uint8 `json:"is_valid"` | ||
Min *FVector `json:"min"` | ||
Max *FVector `json:"max"` | ||
} | ||
|
||
func (parser *PakParser) ReadFBox() *FBox { | ||
return &FBox{ | ||
IsValid: parser.Read(1)[0], | ||
Min: parser.ReadFVector(), | ||
Max: parser.ReadFVector(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package parser | ||
|
||
type FBox2D struct { | ||
IsValid uint8 `json:"is_valid"` | ||
Min *FVector2D `json:"min"` | ||
Max *FVector2D `json:"max"` | ||
} | ||
|
||
func (parser *PakParser) ReadFBox2D() *FBox2D { | ||
return &FBox2D{ | ||
IsValid: parser.Read(1)[0], | ||
Min: parser.ReadFVector2D(), | ||
Max: parser.ReadFVector2D(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package parser | ||
|
||
type FColor struct { | ||
R uint8 `json:"r"` | ||
G uint8 `json:"g"` | ||
B uint8 `json:"b"` | ||
A uint8 `json:"a"` | ||
} | ||
|
||
func (parser *PakParser) ReadFColor() *FColor { | ||
return &FColor{ | ||
R: parser.Read(1)[0], | ||
G: parser.Read(1)[0], | ||
B: parser.Read(1)[0], | ||
A: parser.Read(1)[0], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package parser | ||
|
||
type FFrameNumber struct { | ||
Value int32 `json:"value"` | ||
} | ||
|
||
func (parser *PakParser) ReadFFrameNumber() *FFrameNumber { | ||
return &FFrameNumber{ | ||
Value: parser.ReadInt32(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package parser | ||
|
||
type FGuid struct { | ||
A uint32 `json:"a"` | ||
B uint32 `json:"b"` | ||
C uint32 `json:"c"` | ||
D uint32 `json:"d"` | ||
} | ||
|
||
func (parser *PakParser) ReadFGuid() *FGuid { | ||
return &FGuid{ | ||
A: parser.ReadUint32(), | ||
B: parser.ReadUint32(), | ||
C: parser.ReadUint32(), | ||
D: parser.ReadUint32(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package parser | ||
|
||
type FIntPoint struct { | ||
X int32 `json:"x"` | ||
Y int32 `json:"y"` | ||
} | ||
|
||
func (parser *PakParser) ReadFIntPoint() *FIntPoint { | ||
return &FIntPoint{ | ||
X: parser.ReadInt32(), | ||
Y: parser.ReadInt32(), | ||
} | ||
} |
Oops, something went wrong.