@@ -58,14 +58,21 @@ func (p property) Name() string {
5858}
5959
6060func (p property ) Value () st.PropertyValue {
61+ v := p .entity .Get (p .name )
62+
63+ fs , ok := v .(* fieldState )
64+ if ok {
65+ v = fs .state
66+ }
67+
6168 return st.PropertyValue {
6269 VectorVal : r3.Vector {},
6370 IntVal : 0 ,
6471 Int64Val : 0 ,
6572 ArrayVal : nil ,
6673 StringVal : "" ,
6774 FloatVal : 0 ,
68- Any : p . entity . Get ( p . name ) ,
75+ Any : v ,
6976 S2 : true ,
7077 }
7178}
@@ -416,12 +423,30 @@ func (e *Entity) readFields(r *reader, paths *[]*fieldPath) {
416423 readFieldPaths (r , paths )
417424
418425 for _ , fp := range * paths {
419- decoder := e .class .serializer .getDecoderForFieldPath (fp , 0 )
426+ f := e .class .serializer .getFieldForFieldPath (fp , 0 )
427+ name := e .class .getNameForFieldPath (fp )
428+ decoder , base := e .class .serializer .getDecoderForFieldPath2 (fp , 0 )
420429
421430 val := decoder (r )
422- e .state .set (fp , val )
423431
424- for _ , h := range e .updateHandlers [e .class .getNameForFieldPath (fp )] {
432+ if base && (f .model == fieldModelVariableArray || f .model == fieldModelVariableTable ) {
433+ oldFS := e .state .get (fp )
434+ fs := newFieldState ()
435+
436+ fs .state = make ([]interface {}, val .(uint64 ))
437+
438+ if oldFS != nil {
439+ copy (fs .state , oldFS .(* fieldState ).state [:min (len (fs .state ), len (oldFS .(* fieldState ).state ))])
440+ }
441+
442+ e .state .set (fp , fs )
443+
444+ val = fs .state
445+ } else {
446+ e .state .set (fp , val )
447+ }
448+
449+ for _ , h := range e .updateHandlers [name ] {
425450 h (st.PropertyValue {
426451 VectorVal : r3.Vector {},
427452 IntVal : 0 ,
@@ -446,7 +471,7 @@ func (p *Parser) OnPacketEntities(m *msgs2.CSVCMsg_PacketEntities) error {
446471 index = int32 (- 1 )
447472 updates = int (m .GetUpdatedEntries ())
448473 cmd uint32
449- classId int32
474+ classID int32
450475 serial int32
451476 )
452477
@@ -485,18 +510,18 @@ func (p *Parser) OnPacketEntities(m *msgs2.CSVCMsg_PacketEntities) error {
485510 }
486511 if cmd & 0x01 == 0 {
487512 if cmd & 0x02 != 0 {
488- classId = int32 (r .readBits (p .classIdSize ))
513+ classID = int32 (r .readBits (p .classIdSize ))
489514 serial = int32 (r .readBits (17 ))
490515 r .readVarUint32 ()
491516
492- class := p .classesById [classId ]
517+ class := p .classesById [classID ]
493518 if class == nil {
494- _panicf ("unable to find new class %d" , classId )
519+ _panicf ("unable to find new class %d" , classID )
495520 }
496521
497- baseline := p .classBaselines [classId ]
522+ baseline := p .classBaselines [classID ]
498523 if baseline == nil {
499- _panicf ("unable to find new baseline %d" , classId )
524+ _panicf ("unable to find new baseline %d" , classID )
500525 }
501526
502527 e = newEntity (index , serial , class )
0 commit comments