Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
protobuf: equipment mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa committed Jun 8, 2020
1 parent 41c04d8 commit 066b9e0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Binary file modified examples/minimal.pb
Binary file not shown.
13 changes: 13 additions & 0 deletions protobuf/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,21 @@ func mapToEntityUpdates(entityUpdates []rep.EntityUpdate) []*gen.Replay_Snapshot
Team: mapToTeam(u.Team),
HasHelmet: u.HasHelmet,
HasDefuseKit: u.HasDefuseKit,
Equipment: mapToEquipment(u.Equipment),
})
}

return result
}

func mapToEquipment(equipment []rep.EntityEquipment) []*gen.Replay_Snapshot_EntityEquipment {
result := make([]*gen.Replay_Snapshot_EntityEquipment, 0)
for _, eq := range equipment {
result = append(result, &gen.Replay_Snapshot_EntityEquipment{
Type: int32(eq.Type),
})
}

return result
}

Expand Down
16 changes: 16 additions & 0 deletions protobuf/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ func mapFromEntityUpdates(entityUpdates []*gen.Replay_Snapshot_EntityUpdate) []r
Team: mapFromTeam(u.Team),
HasHelmet: u.HasHelmet,
HasDefuseKit: u.HasDefuseKit,
Equipment: mapFromEquipment(u.Equipment),
}
}

return result
}

func mapFromEquipment(equipment []*gen.Replay_Snapshot_EntityEquipment) []rep.EntityEquipment {
if equipment == nil {
return nil
}

result := make([]rep.EntityEquipment, len(equipment))
for i, eq := range equipment {
result[i] = rep.EntityEquipment{
Type: int(eq.Type),
}
}

Expand Down

0 comments on commit 066b9e0

Please sign in to comment.