|
|
|
@ -4,7 +4,6 @@ import (
|
|
|
|
|
"math"
|
|
|
|
|
|
|
|
|
|
"github.com/jordanorelli/hyperstone/bit"
|
|
|
|
|
"github.com/jordanorelli/hyperstone/dota"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
@ -13,42 +12,38 @@ const (
|
|
|
|
|
f_center
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func floatType(flat *dota.ProtoFlattenedSerializerFieldT, env *Env) tÿpe {
|
|
|
|
|
switch env.symbol(int(flat.GetVarTypeSym())) {
|
|
|
|
|
func floatType(spec *typeSpec, env *Env) tÿpe {
|
|
|
|
|
switch spec.typeName {
|
|
|
|
|
case "CNetworkedQuantizedFloat":
|
|
|
|
|
return qFloatType(flat, env)
|
|
|
|
|
return qFloatType(spec, env)
|
|
|
|
|
case "float32":
|
|
|
|
|
default:
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if env.symbol(int(flat.GetVarEncoderSym())) == "coord" {
|
|
|
|
|
if spec.encoder == "coord" {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if env.symbol(int(flat.GetFieldSerializerNameSym())) == "simulationtime" {
|
|
|
|
|
if spec.serializer == "simulationtime" {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
switch flat.GetBitCount() {
|
|
|
|
|
switch spec.bits {
|
|
|
|
|
case 0, 32:
|
|
|
|
|
Debug.Printf(" std float type")
|
|
|
|
|
return typeFn(float_t)
|
|
|
|
|
default:
|
|
|
|
|
return qFloatType(flat, env)
|
|
|
|
|
return qFloatType(spec, env)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func qFloatType(flat *dota.ProtoFlattenedSerializerFieldT, env *Env) tÿpe {
|
|
|
|
|
if flat.GetBitCount() < 0 {
|
|
|
|
|
func qFloatType(spec *typeSpec, env *Env) tÿpe {
|
|
|
|
|
if spec.bits < 0 {
|
|
|
|
|
return typeError("quantized float has invalid negative bit count specifier")
|
|
|
|
|
}
|
|
|
|
|
if flat.GetHighValue()-flat.GetLowValue() < 0 {
|
|
|
|
|
if spec.high-spec.low < 0 {
|
|
|
|
|
return typeError("quantized float has invalid negative range")
|
|
|
|
|
}
|
|
|
|
|
t := qfloat_t{
|
|
|
|
|
bits: uint(flat.GetBitCount()),
|
|
|
|
|
low: flat.GetLowValue(),
|
|
|
|
|
high: flat.GetHighValue(),
|
|
|
|
|
flags: int(flat.GetEncodeFlags()) & 0x7,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t := qfloat_t{typeSpec: *spec}
|
|
|
|
|
t.span = t.high - t.low
|
|
|
|
|
t.intervals = uint(1<<t.bits - 1)
|
|
|
|
|
t.interval = t.span / float32(t.intervals)
|
|
|
|
@ -72,10 +67,7 @@ func qFloatType(flat *dota.ProtoFlattenedSerializerFieldT, env *Env) tÿpe {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type qfloat_t struct {
|
|
|
|
|
bits uint
|
|
|
|
|
low float32
|
|
|
|
|
high float32
|
|
|
|
|
flags int
|
|
|
|
|
typeSpec
|
|
|
|
|
span float32 // total range of values
|
|
|
|
|
intervals uint // number of intervals in the quantization range
|
|
|
|
|
interval float32 // width of one interval
|
|
|
|
|