From cf787781e9590f467d0389639915548a3f9f55d8 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sun, 25 Sep 2016 00:45:51 -0400 Subject: [PATCH] likely broken cutlvector --- ent/generic.go | 25 +++++++++++++++++-------- ent/type.go | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ent/generic.go b/ent/generic.go index 8ff8897..a37a212 100644 --- a/ent/generic.go +++ b/ent/generic.go @@ -17,19 +17,18 @@ func genericType(spec *typeSpec, env *Env) tÿpe { return typeError("bad generic name: %v", err) } - // genericName, elemName := parts[0], parts[1] - // elemType := func() tÿpe { - // var elemSpec typeSpec - // elemSpec = *spec - // elemSpec.name = elemName - // return parseTypeSpec(&elemSpec, env) - // } + genericName, elemName := parts[0], parts[1] + elemSpec := *spec + elemSpec.typeName = elemName + elem := parseTypeSpec(&elemSpec, env) - switch parts[0] { + switch genericName { case "CHandle", "CStrongHandle": return typeFn(func(r bit.Reader) (value, error) { return handle(bit.ReadVarInt(r)), r.Err() }) + case "CUtlVector": + return cutl_vector_t{elem} default: return typeError("unknown generic name: %v", parts[0]) } @@ -65,5 +64,15 @@ func genericName(name string) ([2]string, error) { if out[1] == "" { return out, fmt.Errorf("empty generic element name") } + Debug.Printf(" generic name in: %s out: %v", name, out) return out, nil } + +type cutl_vector_t struct { + elem tÿpe +} + +func (t cutl_vector_t) read(r bit.Reader) (value, error) { + count := bit.ReadVarInt32(r) + return make(array, count), r.Err() +} diff --git a/ent/type.go b/ent/type.go index 58c5386..8803c0d 100644 --- a/ent/type.go +++ b/ent/type.go @@ -24,6 +24,7 @@ func parseFieldType(flat *dota.ProtoFlattenedSerializerFieldT, env *Env) tÿpe { } func parseTypeSpec(spec *typeSpec, env *Env) tÿpe { + Debug.Printf(" parse spec: %v", spec) coalesce := func(fns ...typeParseFn) tÿpe { for _, fn := range fns { if t := fn(spec, env); t != nil {