forked from paralin/go-dota2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_print_messages.go
55 lines (44 loc) · 1.12 KB
/
cmd_print_messages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"bytes"
"fmt"
"github.com/urfave/cli"
)
func init() {
commands = append(commands, cli.Command{
Name: "print-messages",
Usage: "prints message IDs and derived information",
Action: func(c *cli.Context) error {
m := DumpMessageIDDebug()
fmt.Printf("%s", m)
return nil
},
})
}
// DumpMessageIDDebug dumps debug information about the messages in the system.
func DumpMessageIDDebug() string {
var buf bytes.Buffer
msgIds := getSortedMsgIDs()
var allMethods []string
for _, msgID := range msgIds {
sender := GetMessageSender(msgID)
fmt.Fprintf(&buf, "%d", msgID)
switch sender {
case MsgSenderNone:
buf.WriteString("\tN/A ")
case MsgSenderClient:
buf.WriteString("\tCLIENT")
case MsgSenderGC:
buf.WriteString("\tGC ")
}
fmt.Fprintf(&buf, "\t%s", msgID.String())
if sender == MsgSenderClient {
methodName := GetMessageFuncName(msgID)
fmt.Fprintf(&buf, "\t%s", methodName)
allMethods = append(allMethods, methodName)
}
(&buf).WriteString("\n")
}
(&buf).WriteString(fmt.Sprintf("\nComputed client methods: %v\n", allMethods))
return (&buf).String()
}