Skip to content

Commit

Permalink
Update to v1.0.0 (#91)
Browse files Browse the repository at this point in the history
* wip wip wip

* updated field models

* more field improvements

* cleanup

* isolate new and old behaviors

* fieldpath based state

* add fieldpath lookup

* expose Entity type and API

* passing tests!

* apply patches for old replays

* enhance entity state api

* flesh out entity api

* remove dup call

* like a band-aid

* backward compat for old uint32s

* blackhole names without a fieldpath

* fix var table inspection

* helpers

* pool entity updates for consistent state

* add entity op flag helper

* name, doc cleanup

* fix fieldpath issue, add docs, test

* improve specific errors

* update to go 1.8.3

* support new CUtlString type

* update deps

* update protos

* add parseToTick method to Parser

* add entities test

* fix fieldState set

* update protos
  • Loading branch information
jcoene authored Dec 20, 2017
1 parent fc32336 commit 805b5d4
Show file tree
Hide file tree
Showing 49 changed files with 6,647 additions and 6,115 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ go:
- 1.9.2

install:
- mkdir -p $GOPATH/bin
- curl -s -L https://github.com/Masterminds/glide/releases/download/0.9.3/glide-0.9.3-linux-amd64.tar.gz | tar zxv -C $GOPATH/bin --strip-components=1
- curl -s -L https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz | tar zxv -C $GOPATH/bin --strip-components=1
- glide install

script:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ cpuprofile:
go tool pprof -svg -output=/tmp/manta.cpuprof.svg manta.test /tmp/manta.cpuprof
open /tmp/manta.cpuprof.svg

memprofile:
go test -v -run=TestMatch2159568145 -test.memprofile=/tmp/manta.memprof -test.memprofilerate=1
go tool pprof --alloc_space manta.test /tmp/manta.memprof

update: update-game-tracking gen-dota-proto generate

update-game-tracking:
Expand Down
104 changes: 104 additions & 0 deletions class.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package manta

import (
"fmt"
"math"
"regexp"
"strconv"
"strings"

"github.com/dotabuff/manta/dota"
)

var gameBuildRegexp = regexp.MustCompile(`/dota_v(\d+)/`)

type class struct {
classId int32
name string
serializer *serializer
}

func (c *class) getNameForFieldPath(fp *fieldPath) string {
return strings.Join(c.serializer.getNameForFieldPath(fp, 0), ".")
}

func (c *class) getTypeForFieldPath(fp *fieldPath) *fieldType {
return c.serializer.getTypeForFieldPath(fp, 0)
}

func (c *class) getDecoderForFieldPath(fp *fieldPath) fieldDecoder {
return c.serializer.getDecoderForFieldPath(fp, 0)
}

func (c *class) getFieldPathForName(fp *fieldPath, name string) bool {
return c.serializer.getFieldPathForName(fp, name)
}

func (c *class) getFieldPaths(fp *fieldPath, state *fieldState) []*fieldPath {
return c.serializer.getFieldPaths(fp, state)
}

// Internal callback for OnCSVCMsg_ServerInfo.
func (p *Parser) onCSVCMsg_ServerInfo(m *dota.CSVCMsg_ServerInfo) error {
// This may be needed to parse PacketEntities.
p.classIdSize = uint32(math.Log(float64(m.GetMaxClasses()))/math.Log(2)) + 1

// Extract the build from the game dir.
matches := gameBuildRegexp.FindStringSubmatch(m.GetGameDir())
if len(matches) < 2 {
return fmt.Errorf("unable to determine game build from '%s'", m.GetGameDir())
}
build, err := strconv.ParseUint(matches[1], 10, 32)
if err != nil {
return err
}
p.GameBuild = uint32(build)

return nil
}

// Internal callback for OnCDemoClassInfo.
func (p *Parser) onCDemoClassInfo(m *dota.CDemoClassInfo) error {
for _, c := range m.GetClasses() {
classId := c.GetClassId()
networkName := c.GetNetworkName()

class := &class{
classId: classId,
name: networkName,
serializer: p.serializers[networkName],
}
p.classesById[class.classId] = class
p.classesByName[class.name] = class
}

p.classInfo = true

p.updateInstanceBaseline()

return nil
}

func (p *Parser) updateInstanceBaseline() {
// We can't update the instancebaseline until we have class info.
if !p.classInfo {
return
}

stringTable, ok := p.stringTables.GetTableByName("instancebaseline")
if !ok {
if v(1) {
_debugf("skipping updateInstanceBaseline: no instancebaseline string table")
}
return
}

// Iterate through instancebaseline table items
for _, item := range stringTable.Items {
classId, err := atoi32(item.Key)
if err != nil {
_panicf("invalid instancebaseline key '%s': %s", item.Key, err)
}
p.classBaselines[classId] = item.Value
}
}
110 changes: 0 additions & 110 deletions class_info.go

This file was deleted.

4 changes: 4 additions & 0 deletions dota/base_gcmessages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 805b5d4

Please sign in to comment.