Last active
November 7, 2016 19:33
-
-
Save m1el/2517c6c2e0bb544d84d445a4b3a08599 to your computer and use it in GitHub Desktop.
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
package main | |
import ( | |
"log" | |
"os" | |
"fmt" | |
"github.com/dotabuff/manta" | |
"github.com/dotabuff/manta/dota" | |
) | |
func main() { | |
// Create a new parser instance from a file. Alternatively see NewParser([]byte) | |
if len(os.Args) < 2 { | |
log.Fatalf("missing argument!") | |
} | |
f, err := os.Open(os.Args[1]) | |
if err != nil { | |
log.Fatalf("unable to open file: %s", err) | |
} | |
defer f.Close() | |
parser, err := manta.NewStreamParser(f) | |
if err != nil { | |
log.Fatalf("unable to create parser: %s", err) | |
} | |
parser.OnGameEvent("dota_combatlog", func(m *manta.GameEvent) error { | |
t, err := m.GetInt32("type") | |
if err != nil { | |
log.Printf("unable to get message type: %s\n", err) | |
return nil | |
} | |
switch dota.DOTA_COMBATLOG_TYPES(t) { | |
case dota.DOTA_COMBATLOG_TYPES_DOTA_COMBATLOG_DAMAGE: | |
v, err := m.GetInt32("value") | |
if err != nil { | |
log.Printf("unable to get log value: %s\n", err) | |
return nil | |
} else { | |
fmt.Printf("%d\n", v) | |
} | |
} | |
return nil | |
}) | |
// Start parsing the replay! | |
parser.Start() | |
err = parser.Start() | |
if err != nil { | |
log.Printf("unable to parse demo: %s\n", err) | |
} else { | |
log.Printf("Parse Complete!\n") | |
} | |
} |
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
$ go run damagenumbers.go test.dem | |
panic: unable to find class baseline 697 | |
goroutine 1 [running]: | |
panic(0x631600, 0xc4251cac90) | |
/usr/local/go/src/runtime/panic.go:500 +0x1a1 | |
github.com/dotabuff/manta._panicf(0x777d54, 0x20, 0xc4251b88a0, 0x1, 0x1) | |
/go/src/github.com/dotabuff/manta/util.go:65 +0x83 | |
github.com/dotabuff/manta.(*Parser).onCSVCMsg_PacketEntities(0xc4201a4780, 0xc4250fa680, 0x0, 0x0) | |
/go/src/github.com/dotabuff/manta/packet_entity.go:174 +0xc05 | |
github.com/dotabuff/manta.(*Parser).(github.com/dotabuff/manta.onCSVCMsg_PacketEntities)-fm(0xc4250fa680, 0x963c20, 0xc4250fa680) | |
/go/src/github.com/dotabuff/manta/parser.go:102 +0x34 | |
github.com/dotabuff/manta.(*Callbacks).callByPacketType(0xc420016a00, 0xc400000037, 0xc4251f3512, 0x12a9, 0x12a9, 0x0, 0x0) | |
/go/src/github.com/dotabuff/manta/callbacks.go:2062 +0x3d55 | |
github.com/dotabuff/manta.(*Parser).onCDemoPacket(0xc4201a4780, 0xc4251c5a80, 0x0, 0x0) | |
/go/src/github.com/dotabuff/manta/demo_packet.go:83 +0x378 | |
github.com/dotabuff/manta.(*Parser).(github.com/dotabuff/manta.onCDemoPacket)-fm(0xc4251c5a80, 0x94e060, 0xc4251c5a80) | |
/go/src/github.com/dotabuff/manta/parser.go:96 +0x34 | |
github.com/dotabuff/manta.(*Callbacks).callByDemoType(0xc420016a00, 0xc400000007, 0xc4251f2000, 0x12c6, 0x12c6, 0x0, 0x0) | |
/go/src/github.com/dotabuff/manta/callbacks.go:1367 +0x112f | |
github.com/dotabuff/manta.(*Parser).Start(0xc4201a4780, 0x0, 0x0) | |
/go/src/github.com/dotabuff/manta/parser.go:138 +0xd4 | |
main.main() | |
/go/damagenumbers.go:51 +0x20f | |
exit status 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment