@@ -58,14 +58,21 @@ func (p property) Name() string {
58
58
}
59
59
60
60
func (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
+
61
68
return st.PropertyValue {
62
69
VectorVal : r3.Vector {},
63
70
IntVal : 0 ,
64
71
Int64Val : 0 ,
65
72
ArrayVal : nil ,
66
73
StringVal : "" ,
67
74
FloatVal : 0 ,
68
- Any : p . entity . Get ( p . name ) ,
75
+ Any : v ,
69
76
S2 : true ,
70
77
}
71
78
}
@@ -416,12 +423,30 @@ func (e *Entity) readFields(r *reader, paths *[]*fieldPath) {
416
423
readFieldPaths (r , paths )
417
424
418
425
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 )
420
429
421
430
val := decoder (r )
422
- e .state .set (fp , val )
423
431
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 ] {
425
450
h (st.PropertyValue {
426
451
VectorVal : r3.Vector {},
427
452
IntVal : 0 ,
@@ -446,7 +471,7 @@ func (p *Parser) OnPacketEntities(m *msgs2.CSVCMsg_PacketEntities) error {
446
471
index = int32 (- 1 )
447
472
updates = int (m .GetUpdatedEntries ())
448
473
cmd uint32
449
- classId int32
474
+ classID int32
450
475
serial int32
451
476
)
452
477
@@ -485,18 +510,18 @@ func (p *Parser) OnPacketEntities(m *msgs2.CSVCMsg_PacketEntities) error {
485
510
}
486
511
if cmd & 0x01 == 0 {
487
512
if cmd & 0x02 != 0 {
488
- classId = int32 (r .readBits (p .classIdSize ))
513
+ classID = int32 (r .readBits (p .classIdSize ))
489
514
serial = int32 (r .readBits (17 ))
490
515
r .readVarUint32 ()
491
516
492
- class := p .classesById [classId ]
517
+ class := p .classesById [classID ]
493
518
if class == nil {
494
- _panicf ("unable to find new class %d" , classId )
519
+ _panicf ("unable to find new class %d" , classID )
495
520
}
496
521
497
- baseline := p .classBaselines [classId ]
522
+ baseline := p .classBaselines [classID ]
498
523
if baseline == nil {
499
- _panicf ("unable to find new baseline %d" , classId )
524
+ _panicf ("unable to find new baseline %d" , classID )
500
525
}
501
526
502
527
e = newEntity (index , serial , class )
0 commit comments