From e8ba2c2ca4808746304a24d256ec56d22a5e983c Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Wed, 14 Sep 2016 19:45:48 -0400 Subject: [PATCH] let's try for multiple entities in a packet now --- ent/dict.go | 10 +++++----- ent/selection.go | 1 + ent/type_spec.go | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ent/dict.go b/ent/dict.go index 680dde0..594a8a3 100644 --- a/ent/dict.go +++ b/ent/dict.go @@ -92,8 +92,7 @@ func (d *Dict) updateEntity(id int) error { if e == nil { return fmt.Errorf("update entity %d refused: no such entity", id) } - // e.Read(d.br, d.sr) - return nil + return fillSlots(e, e.Class.String(), d.sr, d.br) } func (d *Dict) deleteEntity(id int) error { @@ -122,7 +121,9 @@ func (d *Dict) Handle(m proto.Message) { d.syncBaselines() case *dota.CSVCMsg_PacketEntities: - d.mergeEntities(v) + if err := d.mergeEntities(v); err != nil { + Debug.Printf("merge entities error: %v", err) + } } } @@ -133,8 +134,7 @@ func (d *Dict) mergeEntities(m *dota.CSVCMsg_PacketEntities) error { d.br.SetSource(data) id := -1 - // for i := 0; i < int(m.GetUpdatedEntries()); i++ { - for i := 0; i < 1; i++ { + for i := 0; i < int(m.GetUpdatedEntries()); i++ { id++ // there may be a jump indicator, indicating how many id positions // to skip. diff --git a/ent/selection.go b/ent/selection.go index 7c4709c..2243a5c 100644 --- a/ent/selection.go +++ b/ent/selection.go @@ -20,6 +20,7 @@ func (s selection) String() string { return fmt.Sprint(s.path()) } func (s selection) path() []int { return s.vals[:s.count] } func (s selection) fill(offset int, displayPath string, dest slotted, br bit.Reader) error { + Debug.Printf("fill selection: %s offset: %d displayPath: %s dest: %v", s, offset, displayPath, dest) slot := s.vals[offset] if s.count-offset <= 0 { panic("selection makes no sense") diff --git a/ent/type_spec.go b/ent/type_spec.go index fc8f79c..a099d2d 100644 --- a/ent/type_spec.go +++ b/ent/type_spec.go @@ -82,7 +82,7 @@ func parseArrayName(s string) (string, int) { n, err := strconv.Atoi(ns) if err != nil { n = cIdents[ns] - if n == 0 { + if n <= 0 { panic("invalid array type name: " + err.Error()) } }