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