-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
49 changed files
with
6,647 additions
and
6,115 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
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,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 | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.