MCPcopy Create free account
hub / github.com/dotabuff/manta / emitModifierTableEvents

Method emitModifierTableEvents

modifier.go:18–48  ·  view source on GitHub ↗

emitModifierTableEvents emits ModifierBuffTableEntry events from the given string table items.

(items []*stringTableItem)

Source from the content-addressed store, hash-verified

16// emitModifierTableEvents emits ModifierBuffTableEntry events
17// from the given string table items.
18func (p *Parser) emitModifierTableEvents(items []*stringTableItem) error {
19 // Nothing to do if no consumer is listening; avoid the per-item proto
20 // allocation + unmarshal entirely. This is the common case (e.g. the
21 // benchmark and any parse that doesn't register OnModifierTableEntry).
22 if len(p.modifierTableEntryHandlers) == 0 {
23 return nil
24 }
25
26 for _, item := range items {
27 // Skip deleted/empty entries (clarity does the same). An empty value
28 // would otherwise unmarshal into an all-zero message and be emitted as a
29 // spurious modifier event. A real modifier is never zero-length on wire.
30 if len(item.Value) == 0 {
31 continue
32 }
33
34 msg := &dota.CDOTAModifierBuffTableEntry{}
35 if err := proto.NewBuffer(item.Value).Unmarshal(msg); err != nil {
36 _debugf("unable to unmarshal ModifierBuffTableEntry: %s", err)
37 continue
38 }
39
40 for _, fn := range p.modifierTableEntryHandlers {
41 if err := fn(msg); err != nil {
42 return err
43 }
44 }
45 }
46
47 return nil
48}

Callers 2

Calls 1

_debugfFunction · 0.85

Tested by

no test coverage detected