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

Commit

Permalink
deps: upgrade demoinfocs to v2 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa authored May 8, 2020
1 parent a2e187c commit 703cd25
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 26 deletions.
22 changes: 11 additions & 11 deletions csminify.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"math"

r3 "github.com/golang/geo/r3"
dem "github.com/markus-wa/demoinfocs-golang"
events "github.com/markus-wa/demoinfocs-golang/events"
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"

rep "github.com/markus-wa/cs-demo-minifier/replay"
)
Expand Down Expand Up @@ -107,14 +107,14 @@ func ToReplayWithConfig(r io.Reader, cfg ReplayConfig) (rep.Replay, error) {
}

type minifier struct {
parser *dem.Parser
parser dem.Parser
replay rep.Replay
eventCollector *EventCollector

knownPlayerEntityIDs map[int]struct{}
}

func newMinifier(parser *dem.Parser, eventCollector *EventCollector) minifier {
func newMinifier(parser dem.Parser, eventCollector *EventCollector) minifier {
return minifier{
parser: parser,
eventCollector: eventCollector,
Expand Down Expand Up @@ -155,14 +155,14 @@ func (m *minifier) snapshot() rep.Snapshot {
if pl.IsAlive() {
e := rep.EntityUpdate{
EntityID: pl.EntityID,
Hp: pl.Hp,
Armor: pl.Armor,
Hp: pl.Health(),
Armor: pl.Armor(),
FlashDuration: float32(roundTo(float64(pl.FlashDuration), 0.1)), // Round to nearest 0.1 sec - saves space in JSON
Positions: []rep.Point{r3VectorToPoint(pl.Position)},
AngleX: int(pl.ViewDirectionX),
AngleY: int(pl.ViewDirectionY),
HasHelmet: pl.HasHelmet,
HasDefuseKit: pl.HasDefuseKit,
Positions: []rep.Point{r3VectorToPoint(pl.Position())},
AngleX: int(pl.ViewDirectionX()),
AngleY: int(pl.ViewDirectionY()),
HasHelmet: pl.HasHelmet(),
HasDefuseKit: pl.HasDefuseKit(),
}

// FIXME: Smoothify Positions
Expand Down
14 changes: 7 additions & 7 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package csminify

import (
rep "github.com/markus-wa/cs-demo-minifier/replay"
dem "github.com/markus-wa/demoinfocs-golang"
events "github.com/markus-wa/demoinfocs-golang/events"
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
)

// EventCollector provides the possibility of adding custom events to replays.
Expand All @@ -14,15 +14,15 @@ import (
type EventCollector struct {
handlers []interface{}
events []rep.Event
parser *dem.Parser
parser dem.Parser
}

// AddHandler adds a handler which will be registered on the Parser to the collector.
// The handler should use EventCollector.AddEvent() and be of the type
// func(<EventType>) where EventType is the type of the event to be handled.
// The handler parameter is of type interface because lolnogenerics.
// See: github.com/markus-wa/demoinfocs-golang demoinfocs.Parser.RegisterEventHandler()
// GoDoc: https://godoc.org/github.com/markus-wa/demoinfocs-golang#Parser.RegisterEventHandler
// See: github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs.Parser.RegisterEventHandler()
// GoDoc: https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs?tab=doc#Parser
func (ec *EventCollector) AddHandler(handler interface{}) {
ec.handlers = append(ec.handlers, handler)
}
Expand All @@ -35,7 +35,7 @@ func (ec *EventCollector) AddEvent(event rep.Event) {

// Parser returns the demo-parser through which custom handlers can access game-state information.
// Returns nil before minification has started - so don't call this before you need it.
func (ec *EventCollector) Parser() *dem.Parser {
func (ec *EventCollector) Parser() dem.Parser {
return ec.parser
}

Expand Down Expand Up @@ -101,7 +101,7 @@ func (defaultEventHandlers) RegisterPlayerKilled(ec *EventCollector) {
ec.AddHandler(func(e events.Kill) {
eb := buildEvent(rep.EventKill)
eb.intAttr(rep.AttrKindVictim, e.Victim.EntityID)
eb.intAttr(rep.AttrKindWeapon, int(e.Weapon.Weapon))
eb.intAttr(rep.AttrKindWeapon, int(e.Weapon.Type))

if e.Killer != nil {
eb.intAttr(rep.AttrKindKiller, e.Killer.EntityID)
Expand Down
6 changes: 3 additions & 3 deletions events.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
| attribute | type | description |
| --- | --- | --- |
| `victim` | `numVal` | EntityID |
| `weapon` | `numVal` | see [`EquipmentElement`](https://godoc.org/github.com/markus-wa/demoinfocs-golang/common#EquipmentElement) |
| `weapon` | `numVal` | see [`EquipmentType`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common?tab=doc#EquipmentType) |
| `killer` | `numVal` | EntityID |
| `assister` | `numVal` | EntityID |

Expand Down Expand Up @@ -82,5 +82,5 @@

| attribute | type | description |
| --- | --- | --- |
| `winner` | `numVal` | see [`Team`](https://godoc.org/github.com/markus-wa/demoinfocs-golang/common#Team) |
| `reason` | `numVal` | see [`RoundEndReason`](https://godoc.org/github.com/markus-wa/demoinfocs-golang/events#RoundEndReason) |
| `winner` | `numVal` | see [`Team`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common?tab=doc#Team) |
| `reason` | `numVal` | see [`RoundEndReason`](https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events?tab=doc#RoundEndReason) |
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/markus-wa/cs-demo-minifier
require (
github.com/alecthomas/jsonschema v0.0.0-20191017121752-4bb6e3fae4f2
github.com/gogo/protobuf v1.3.1
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d
github.com/golang/protobuf v1.3.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/markus-wa/demoinfocs-golang v1.10.0
github.com/markus-wa/demoinfocs-golang/v2 v2.0.0-beta.11
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.5.1
github.com/vishalkuo/bimap v0.0.0-20180703190407-09cff2814645
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw
github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec h1:lJwO/92dFXWeXOZdoGXgptLmNLwynMSHUmU6besqtiw=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d h1:C/hKUcHT483btRbeGkrRjJz+Zbcj8audldIi9tRJDCc=
github.com/golang/geo v0.0.0-20200319012246-673a6f80352d/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down Expand Up @@ -37,6 +39,8 @@ github.com/markus-wa/demoinfocs-golang v1.8.0 h1:0SjDccHAAMsgqRgRfFJVGdB5hDckF6q
github.com/markus-wa/demoinfocs-golang v1.8.0/go.mod h1:KPgRV6eiqcfwk5bpgjEiU5LChiNvu1LI14Vo6qMgzPc=
github.com/markus-wa/demoinfocs-golang v1.10.0 h1:XgGsUG2jBIWT6yqkKqWg3Xh671acQiilDi4/xrKNwTY=
github.com/markus-wa/demoinfocs-golang v1.10.0/go.mod h1:89I5cRCmxICDQHt0KzWURFhGgKstC1rwqUrsmVckDcM=
github.com/markus-wa/demoinfocs-golang/v2 v2.0.0-beta.11 h1:GcOTLYPUzA30+bokg7MyBhJoDuIN9+5LaPyIAVpmkoc=
github.com/markus-wa/demoinfocs-golang/v2 v2.0.0-beta.11/go.mod h1:8Jj8IZRuSCZLYK1E6JMmhegDotSkDAdntzyGEzy2pbU=
github.com/markus-wa/go-unassert v0.1.1 h1:Bn7NfuD85DFdUoGQREI3PWNT1m0THYbYazHmOVIPNYQ=
github.com/markus-wa/go-unassert v0.1.1/go.mod h1:XEvrxR+trvZeMDfXcZPvzqGo6eumEtdk5VjNRuvvzxQ=
github.com/markus-wa/go-unassert v0.1.2 h1:uXWlMDa8JVtc4RgNq4XJIjyRejv9MOVuy/E0VECPxxo=
Expand Down
2 changes: 1 addition & 1 deletion marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"testing"

"github.com/markus-wa/demoinfocs-golang/events"
"github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"
"github.com/stretchr/testify/assert"
"gopkg.in/vmihailenco/msgpack.v2"

Expand Down
2 changes: 1 addition & 1 deletion protobuf/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package protobuf
import (
io "io"

common "github.com/markus-wa/demoinfocs-golang/common"
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"

gen "github.com/markus-wa/cs-demo-minifier/protobuf/gen"
rep "github.com/markus-wa/cs-demo-minifier/replay"
Expand Down
2 changes: 1 addition & 1 deletion protobuf/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"io/ioutil"

common "github.com/markus-wa/demoinfocs-golang/common"
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"

gen "github.com/markus-wa/cs-demo-minifier/protobuf/gen"
rep "github.com/markus-wa/cs-demo-minifier/replay"
Expand Down

0 comments on commit 703cd25

Please sign in to comment.