types
Jordan Orelli 8 years ago
parent 557d34dfd1
commit fd45738324

@ -29,6 +29,15 @@ var atom_types = map[string]typeFn{
"CUtlStringToken": func(r bit.Reader) (value, error) { "CUtlStringToken": func(r bit.Reader) (value, error) {
return bit.ReadVarInt(r), r.Err() return bit.ReadVarInt(r), r.Err()
}, },
"Color": func(r bit.Reader) (value, error) {
u := bit.ReadVarInt(r)
return color{
r: uint8(u >> 6 & 0xff),
g: uint8(u >> 4 & 0xff),
b: uint8(u >> 2 & 0xff),
a: uint8(u >> 0 & 0xff),
}, r.Err()
},
} }
func atomType(spec *typeSpec, env *Env) tÿpe { func atomType(spec *typeSpec, env *Env) tÿpe {
@ -38,3 +47,5 @@ func atomType(spec *typeSpec, env *Env) tÿpe {
} }
return nil return nil
} }
type color struct{ r, g, b, a uint8 }

@ -26,12 +26,12 @@ func genericType(spec *typeSpec, env *Env) tÿpe {
// } // }
switch parts[0] { switch parts[0] {
case "CStrongHandle": case "CHandle", "CStrongHandle":
return typeFn(func(r bit.Reader) (value, error) { return typeFn(func(r bit.Reader) (value, error) {
return handle(bit.ReadVarInt(r)), r.Err() return handle(bit.ReadVarInt(r)), r.Err()
}) })
default: default:
return typeError("unknown generic name: %v", genericName) return typeError("unknown generic name: %v", parts[0])
} }
} }

Loading…
Cancel
Save