Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/commands/commit-staged.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Great, thanks! I staged your changes, please make a commit.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.claude/settings.local.json
/manta
/manta.test
/replays/*.dem*
Expand Down
24 changes: 1 addition & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
SED=sed
ifeq ($(shell uname), Darwin)
SED=gsed
endif

default: build

test:
Expand Down Expand Up @@ -30,24 +25,7 @@ memprofile:
update: update-protobufs generate

update-protobufs:
rm -rf dota
mkdir -p ./dota/tmp && \
curl -L -o - https://github.com/SteamDatabase/GameTracking-Dota2/archive/master.tar.gz | tar -xz --strip-components=1 -C ./dota/tmp && \
cp -a ./dota/tmp/Protobufs/*.proto ./dota/ && \
rm -rf ./dota/tmp
rm -rf dota/gametoolevents.proto dota/dota_messages_mlbot.proto dota/dota_gcmessages_common_bot_script.proto dota/steammessages_base.proto dota/steammessages_clientserver_login.proto dota/tensorflow
$(SED) -i 's/\.CMsgFightingGame_GameData/CMsgFightingGame_GameData/g' dota/dota_fighting_game_p2p_messages.proto
$(SED) -i 's/^\(\s*\)\(optional\|repeated\|required\|extend\)\s*\./\1\2 /' dota/*.proto
$(SED) -i 's!^\s*rpc\s*\(\S*\)\s*(\.\([^)]*\))\s*returns\s*(\.\([^)]*\))\s*{!rpc \1 (\2) returns (\3) {!' dota/*.proto
$(SED) -i '1isyntax = "proto2";\n\npackage dota;\noption go_package = "github.com/dotabuff/manta/dota;dota";\n' dota/*.proto
$(SED) -i '/^import "google\/protobuf\/valve_extensions\.proto"/d' dota/*.proto
$(SED) -i '/^option (/d' dota/*.proto
$(SED) -i 's/\s\[.*\]//g' dota/*.proto
$(SED) -i 's/\.CMsgSteamLearn/CMsgSteamLearn/g' dota/*.proto
$(SED) -i 's/\.CMsgShowcaseItem/CMsgShowcaseItem/g' dota/*.proto
$(SED) -i 's/\.CMsgShowcaseBackground/CMsgShowcaseBackground/g' dota/*.proto
$(SED) -i 's/\.CMsgSurvivorsUserData/CMsgSurvivorsUserData/g' dota/*.proto
protoc -I dota --go_out=paths=source_relative:dota dota/*.proto
go run gen/updateprotos/main.go

generate:
go run gen/callbacks.go
Expand Down
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,7 @@ func main() {

## Developing

To run `make update` you will need a few things installed:

```sh
# Install subversion. On OS X:
brew install subversion

# Install protoc. On OS X:
brew install protobuf

# Install gnu-sed. Not needed on Linux. On OS X:
brew install gnu-sed

# Install protoc-gen-go:
go install github.com/golang/protobuf/protoc-gen-go@v1.5.2
```
You can run `make update` to re-generate protobufs and callbacks based on the [SteamDatabase/Protobufs](https://github.com/SteamDatabase/Protobufs) project.

## License

Expand All @@ -87,6 +73,7 @@ Looking to parse Source 1 (original Dota 2) replays? Take a look at [Yasha](http

Manta is maintained and development is sponsored by [Dotabuff](http://www.dotabuff.com), a leading Dota 2 community website with an emphasis on statistics. Manta wouldn't exist without the efforts of a number of people:

- [Jason Coene](https://github.com/jcoene) is the long-time primary maintainer of the project
- [Michael Fellinger](https://github.com/manveru) built Dotabuff's Source 1 parser [yasha](https://github.com/dotabuff/yasha).
- [Robin Dietrich](https://github.com/invokr) built the C++ parser [Alice](https://github.com/AliceStats/Alice).
- [Martin Schrodt](https://github.com/spheenik) built the Java parser [clarity](https://github.com/skadistats/clarity).
Expand Down
191 changes: 183 additions & 8 deletions callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Callbacks struct {
onCSVCMsg_UserMessage []func(*dota.CSVCMsg_UserMessage) error
onCSVCMsg_Broadcast_Command []func(*dota.CSVCMsg_Broadcast_Command) error
onCSVCMsg_HltvFixupOperatorStatus []func(*dota.CSVCMsg_HltvFixupOperatorStatus) error
onCSVCMsg_NextMsgPredicted []func(*dota.CSVCMsg_NextMsgPredicted) error
onCUserMessageAchievementEvent []func(*dota.CUserMessageAchievementEvent) error
onCUserMessageCloseCaption []func(*dota.CUserMessageCloseCaption) error
onCUserMessageCloseCaptionDirect []func(*dota.CUserMessageCloseCaptionDirect) error
Expand Down Expand Up @@ -116,7 +117,7 @@ type Callbacks struct {
onCMsgPlaceDecalEvent []func(*dota.CMsgPlaceDecalEvent) error
onCMsgClearWorldDecalsEvent []func(*dota.CMsgClearWorldDecalsEvent) error
onCMsgClearEntityDecalsEvent []func(*dota.CMsgClearEntityDecalsEvent) error
onCMsgClearDecalsForSkeletonInstanceEvent []func(*dota.CMsgClearDecalsForSkeletonInstanceEvent) error
onCMsgClearDecalsForEntityEvent []func(*dota.CMsgClearDecalsForEntityEvent) error
onCMsgSource1LegacyGameEventList []func(*dota.CMsgSource1LegacyGameEventList) error
onCMsgSource1LegacyListenEvents []func(*dota.CMsgSource1LegacyListenEvents) error
onCMsgSource1LegacyGameEvent []func(*dota.CMsgSource1LegacyGameEvent) error
Expand Down Expand Up @@ -279,6 +280,12 @@ type Callbacks struct {
onCDOTAUserMsg_NeutralCraftAvailable []func(*dota.CDOTAUserMsg_NeutralCraftAvailable) error
onCDOTAUserMsg_TimerAlert []func(*dota.CDOTAUserMsg_TimerAlert) error
onCDOTAUserMsg_MadstoneAlert []func(*dota.CDOTAUserMsg_MadstoneAlert) error
onCDOTAUserMsg_CourierLeftFountainAlert []func(*dota.CDOTAUserMsg_CourierLeftFountainAlert) error
onCDOTAUserMsg_MonsterHunter_InvestigationsAvailable []func(*dota.CDOTAUserMsg_MonsterHunter_InvestigationsAvailable) error
onCDOTAUserMsg_MonsterHunter_InvestigationGameState []func(*dota.CDOTAUserMsg_MonsterHunter_InvestigationGameState) error
onCDOTAUserMsg_MonsterHunter_HuntAlert []func(*dota.CDOTAUserMsg_MonsterHunter_HuntAlert) error
onCDOTAUserMsg_TormentorTimer []func(*dota.CDOTAUserMsg_TormentorTimer) error
onCDOTAUserMsg_KillEffect []func(*dota.CDOTAUserMsg_KillEffect) error

pb *proto.Buffer
}
Expand Down Expand Up @@ -589,6 +596,11 @@ func (c *Callbacks) OnCSVCMsg_HltvFixupOperatorStatus(fn func(*dota.CSVCMsg_Hltv
c.onCSVCMsg_HltvFixupOperatorStatus = append(c.onCSVCMsg_HltvFixupOperatorStatus, fn)
}

// OnCSVCMsg_NextMsgPredicted registers a callback for SVC_Messages_svc_NextMsgPredicted
func (c *Callbacks) OnCSVCMsg_NextMsgPredicted(fn func(*dota.CSVCMsg_NextMsgPredicted) error) {
c.onCSVCMsg_NextMsgPredicted = append(c.onCSVCMsg_NextMsgPredicted, fn)
}

// OnCUserMessageAchievementEvent registers a callback for EBaseUserMessages_UM_AchievementEvent
func (c *Callbacks) OnCUserMessageAchievementEvent(fn func(*dota.CUserMessageAchievementEvent) error) {
c.onCUserMessageAchievementEvent = append(c.onCUserMessageAchievementEvent, fn)
Expand Down Expand Up @@ -834,9 +846,9 @@ func (c *Callbacks) OnCMsgClearEntityDecalsEvent(fn func(*dota.CMsgClearEntityDe
c.onCMsgClearEntityDecalsEvent = append(c.onCMsgClearEntityDecalsEvent, fn)
}

// OnCMsgClearDecalsForSkeletonInstanceEvent registers a callback for EBaseGameEvents_GE_ClearDecalsForSkeletonInstanceEvent
func (c *Callbacks) OnCMsgClearDecalsForSkeletonInstanceEvent(fn func(*dota.CMsgClearDecalsForSkeletonInstanceEvent) error) {
c.onCMsgClearDecalsForSkeletonInstanceEvent = append(c.onCMsgClearDecalsForSkeletonInstanceEvent, fn)
// OnCMsgClearDecalsForEntityEvent registers a callback for EBaseGameEvents_GE_ClearDecalsForEntityEvent
func (c *Callbacks) OnCMsgClearDecalsForEntityEvent(fn func(*dota.CMsgClearDecalsForEntityEvent) error) {
c.onCMsgClearDecalsForEntityEvent = append(c.onCMsgClearDecalsForEntityEvent, fn)
}

// OnCMsgSource1LegacyGameEventList registers a callback for EBaseGameEvents_GE_Source1LegacyGameEventList
Expand Down Expand Up @@ -1649,6 +1661,36 @@ func (c *Callbacks) OnCDOTAUserMsg_MadstoneAlert(fn func(*dota.CDOTAUserMsg_Mads
c.onCDOTAUserMsg_MadstoneAlert = append(c.onCDOTAUserMsg_MadstoneAlert, fn)
}

// OnCDOTAUserMsg_CourierLeftFountainAlert registers a callback for EDotaUserMessages_DOTA_UM_CourierLeftFountainAlert
func (c *Callbacks) OnCDOTAUserMsg_CourierLeftFountainAlert(fn func(*dota.CDOTAUserMsg_CourierLeftFountainAlert) error) {
c.onCDOTAUserMsg_CourierLeftFountainAlert = append(c.onCDOTAUserMsg_CourierLeftFountainAlert, fn)
}

// OnCDOTAUserMsg_MonsterHunter_InvestigationsAvailable registers a callback for EDotaUserMessages_DOTA_UM_MonsterHunter_InvestigationsAvailable
func (c *Callbacks) OnCDOTAUserMsg_MonsterHunter_InvestigationsAvailable(fn func(*dota.CDOTAUserMsg_MonsterHunter_InvestigationsAvailable) error) {
c.onCDOTAUserMsg_MonsterHunter_InvestigationsAvailable = append(c.onCDOTAUserMsg_MonsterHunter_InvestigationsAvailable, fn)
}

// OnCDOTAUserMsg_MonsterHunter_InvestigationGameState registers a callback for EDotaUserMessages_DOTA_UM_MonsterHunter_InvestigationGameState
func (c *Callbacks) OnCDOTAUserMsg_MonsterHunter_InvestigationGameState(fn func(*dota.CDOTAUserMsg_MonsterHunter_InvestigationGameState) error) {
c.onCDOTAUserMsg_MonsterHunter_InvestigationGameState = append(c.onCDOTAUserMsg_MonsterHunter_InvestigationGameState, fn)
}

// OnCDOTAUserMsg_MonsterHunter_HuntAlert registers a callback for EDotaUserMessages_DOTA_UM_MonsterHunter_HuntAlert
func (c *Callbacks) OnCDOTAUserMsg_MonsterHunter_HuntAlert(fn func(*dota.CDOTAUserMsg_MonsterHunter_HuntAlert) error) {
c.onCDOTAUserMsg_MonsterHunter_HuntAlert = append(c.onCDOTAUserMsg_MonsterHunter_HuntAlert, fn)
}

// OnCDOTAUserMsg_TormentorTimer registers a callback for EDotaUserMessages_DOTA_UM_TormentorTimer
func (c *Callbacks) OnCDOTAUserMsg_TormentorTimer(fn func(*dota.CDOTAUserMsg_TormentorTimer) error) {
c.onCDOTAUserMsg_TormentorTimer = append(c.onCDOTAUserMsg_TormentorTimer, fn)
}

// OnCDOTAUserMsg_KillEffect registers a callback for EDotaUserMessages_DOTA_UM_KillEffect
func (c *Callbacks) OnCDOTAUserMsg_KillEffect(fn func(*dota.CDOTAUserMsg_KillEffect) error) {
c.onCDOTAUserMsg_KillEffect = append(c.onCDOTAUserMsg_KillEffect, fn)
}

func (c *Callbacks) callByDemoType(t int32, buf []byte) error {
switch t {
case 0: // dota.EDemoCommands_DEM_Stop
Expand Down Expand Up @@ -2802,6 +2844,25 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 77: // dota.SVC_Messages_svc_NextMsgPredicted
if c.onCSVCMsg_NextMsgPredicted == nil {
return nil
}

msg := &dota.CSVCMsg_NextMsgPredicted{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCSVCMsg_NextMsgPredicted {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 101: // dota.EBaseUserMessages_UM_AchievementEvent
if c.onCUserMessageAchievementEvent == nil {
return nil
Expand Down Expand Up @@ -3733,18 +3794,18 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 204: // dota.EBaseGameEvents_GE_ClearDecalsForSkeletonInstanceEvent
if c.onCMsgClearDecalsForSkeletonInstanceEvent == nil {
case 204: // dota.EBaseGameEvents_GE_ClearDecalsForEntityEvent
if c.onCMsgClearDecalsForEntityEvent == nil {
return nil
}

msg := &dota.CMsgClearDecalsForSkeletonInstanceEvent{}
msg := &dota.CMsgClearDecalsForEntityEvent{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCMsgClearDecalsForSkeletonInstanceEvent {
for _, fn := range c.onCMsgClearDecalsForEntityEvent {
if err := fn(msg); err != nil {
return err
}
Expand Down Expand Up @@ -6830,6 +6891,120 @@ func (c *Callbacks) callByPacketType(t int32, buf []byte) error {

return nil

case 630: // dota.EDotaUserMessages_DOTA_UM_CourierLeftFountainAlert
if c.onCDOTAUserMsg_CourierLeftFountainAlert == nil {
return nil
}

msg := &dota.CDOTAUserMsg_CourierLeftFountainAlert{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCDOTAUserMsg_CourierLeftFountainAlert {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 631: // dota.EDotaUserMessages_DOTA_UM_MonsterHunter_InvestigationsAvailable
if c.onCDOTAUserMsg_MonsterHunter_InvestigationsAvailable == nil {
return nil
}

msg := &dota.CDOTAUserMsg_MonsterHunter_InvestigationsAvailable{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCDOTAUserMsg_MonsterHunter_InvestigationsAvailable {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 632: // dota.EDotaUserMessages_DOTA_UM_MonsterHunter_InvestigationGameState
if c.onCDOTAUserMsg_MonsterHunter_InvestigationGameState == nil {
return nil
}

msg := &dota.CDOTAUserMsg_MonsterHunter_InvestigationGameState{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCDOTAUserMsg_MonsterHunter_InvestigationGameState {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 633: // dota.EDotaUserMessages_DOTA_UM_MonsterHunter_HuntAlert
if c.onCDOTAUserMsg_MonsterHunter_HuntAlert == nil {
return nil
}

msg := &dota.CDOTAUserMsg_MonsterHunter_HuntAlert{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCDOTAUserMsg_MonsterHunter_HuntAlert {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 634: // dota.EDotaUserMessages_DOTA_UM_TormentorTimer
if c.onCDOTAUserMsg_TormentorTimer == nil {
return nil
}

msg := &dota.CDOTAUserMsg_TormentorTimer{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCDOTAUserMsg_TormentorTimer {
if err := fn(msg); err != nil {
return err
}
}

return nil

case 635: // dota.EDotaUserMessages_DOTA_UM_KillEffect
if c.onCDOTAUserMsg_KillEffect == nil {
return nil
}

msg := &dota.CDOTAUserMsg_KillEffect{}
c.pb.SetBuf(buf)
if err := c.pb.Unmarshal(msg); err != nil {
return err
}

for _, fn := range c.onCDOTAUserMsg_KillEffect {
if err := fn(msg); err != nil {
return err
}
}

return nil

}

return nil
Expand Down
Loading