Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions internal/storage/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,25 @@ type Event struct {

// EntityDef defines an entity's metadata
type EntityDef struct {
ID uint32 `json:"id"`
Type string `json:"type"` // "unit" or "vehicle"
Name string `json:"name"`
Side string `json:"side"`
Group string `json:"group"`
Role string `json:"role"`
StartFrame uint32 `json:"startFrame"`
EndFrame uint32 `json:"endFrame"`
IsPlayer bool `json:"isPlayer"`
VehicleClass string `json:"vehicleClass,omitempty"`
ID uint32 `json:"id"`
Type string `json:"type"` // "unit" or "vehicle"
Name string `json:"name"`
Side string `json:"side"`
Group string `json:"group"`
Role string `json:"role"`
StartFrame uint32 `json:"startFrame"`
EndFrame uint32 `json:"endFrame"`
IsPlayer bool `json:"isPlayer"`
VehicleClass string `json:"vehicleClass,omitempty"`
FramesFired []FiredFrame `json:"framesFired,omitempty"`
}

// FiredFrame represents a projectile fired at a specific frame
type FiredFrame struct {
FrameNum uint32 `json:"frameNum"`
PosX float32 `json:"posX"`
PosY float32 `json:"posY"`
PosZ float32 `json:"posZ"`
}

// Chunk contains position data for a frame range
Expand Down
35 changes: 35 additions & 0 deletions internal/storage/parser_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (p *ParserV1) Parse(data map[string]interface{}, chunkSize uint32) (*ParseR
EndFrame: endFrame,
IsPlayer: getFloat64(em, "isPlayer") == 1,
VehicleClass: getString(em, "class"),
FramesFired: p.parseFramesFired(em),
}
result.Entities = append(result.Entities, def)

Expand Down Expand Up @@ -433,3 +434,37 @@ func sideIndexToString(idx int) string {
return ""
}
}

// parseFramesFired extracts fired frame data from an entity
// Format: [[frameNum, [x, y, z]], ...]
func (p *ParserV1) parseFramesFired(em map[string]interface{}) []FiredFrame {
framesFired, ok := em["framesFired"].([]interface{})
if !ok {
return nil
}

result := make([]FiredFrame, 0, len(framesFired))
for _, ff := range framesFired {
arr, ok := ff.([]interface{})
if !ok || len(arr) < 2 {
continue
}

frame := FiredFrame{
FrameNum: uint32(toFloat64(arr[0])),
}

// Parse position [x, y, z]
if posArr, ok := arr[1].([]interface{}); ok && len(posArr) >= 2 {
frame.PosX = float32(toFloat64(posArr[0]))
frame.PosY = float32(toFloat64(posArr[1]))
if len(posArr) > 2 {
frame.PosZ = float32(toFloat64(posArr[2]))
}
}

result = append(result, frame)
}

return result
}
14 changes: 13 additions & 1 deletion internal/storage/writer_protobuf_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (w *ProtobufWriterV1) toProtoManifest(result *ParseResult) *pbv1.Manifest {

// toProtoEntityDef converts schema-agnostic EntityDef to pbv1.EntityDef
func (w *ProtobufWriterV1) toProtoEntityDef(e EntityDef) *pbv1.EntityDef {
return &pbv1.EntityDef{
def := &pbv1.EntityDef{
Id: e.ID,
Type: w.stringToEntityType(e.Type),
Name: e.Name,
Expand All @@ -142,6 +142,18 @@ func (w *ProtobufWriterV1) toProtoEntityDef(e EntityDef) *pbv1.EntityDef {
IsPlayer: e.IsPlayer,
VehicleClass: e.VehicleClass,
}

// Convert frames fired
for _, ff := range e.FramesFired {
def.FramesFired = append(def.FramesFired, &pbv1.FiredFrame{
FrameNum: ff.FrameNum,
PosX: ff.PosX,
PosY: ff.PosY,
PosZ: ff.PosZ,
})
}

return def
}

// toProtoEvent converts schema-agnostic Event to pbv1.Event
Expand Down
Loading
Loading