1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "quakedef.h"
#include "dt.h"
#include "dt_encode.h"
#include "coordsize.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
extern void DataTable_Warning( const char *pInMessage, ... );
extern bool ShouldWatchThisProp( const SendTable *pTable, int objectID, const char *pPropName );
// The engine implements this.
extern const char* GetObjectClassName( int objectID );
void EncodeFloat( const SendProp *pProp, float fVal, bf_write *pOut, int objectID )
{
// Check for special flags like SPROP_COORD, SPROP_NOSCALE, and SPROP_NORMAL.
int flags = pProp->GetFlags();
if ( flags & SPROP_COORD )
{
pOut->WriteBitCoord( fVal );
}
else if ( flags & ( SPROP_COORD_MP | SPROP_COORD_MP_LOWPRECISION | SPROP_COORD_MP_INTEGRAL ) )
{
COMPILE_TIME_ASSERT( SPROP_COORD_MP_INTEGRAL == (1<<15) );
COMPILE_TIME_ASSERT( SPROP_COORD_MP_LOWPRECISION == (1<<14) );
pOut->WriteBitCoordMP( fVal, ((flags >> 15) & 1), ((flags >> 14) & 1) );
}
else if ( flags & SPROP_NORMAL )
{
pOut->WriteBitNormal( fVal );
}
else // standard clamped-range float
{
unsigned long ulVal;
int nBits = pProp->m_nBits;
if ( flags & SPROP_NOSCALE )
{
union { float f; uint32 u; } convert = { fVal };
ulVal = convert.u;
nBits = 32;
}
else if( fVal < pProp->m_fLowValue )
{
// clamp < 0
ulVal = 0;
if(!(flags & SPROP_ROUNDUP))
{
DataTable_Warning("(class %s): Out-of-range value (%f / %f) in SendPropFloat '%s', clamping.\n",
GetObjectClassName( objectID ), fVal, pProp->m_fLowValue, pProp->m_pVarName );
}
}
else if( fVal > pProp->m_fHighValue )
{
// clamp > 1
ulVal = ((1 << pProp->m_nBits) - 1);
if(!(flags & SPROP_ROUNDDOWN))
{
DataTable_Warning("%s: Out-of-range value (%f/%f) in SendPropFloat '%s', clamping.\n",
GetObjectClassName( objectID ), fVal, pProp->m_fHighValue, pProp->m_pVarName );
}
}
else
{
float fRangeVal = (fVal - pProp->m_fLowValue) * pProp->m_fHighLowMul;
if ( pProp->m_nBits <= 22 )
{
// this is the case we always expect to hit
ulVal = FastFloatToSmallInt( fRangeVal );
}
else
{
// retain old logic just in case anyone relies on its behavior
ulVal = RoundFloatToUnsignedLong( fRangeVal );
}
}
pOut->WriteUBitLong(ulVal, nBits);
}
}
static float DecodeFloat(SendProp const *pProp, bf_read *pIn)
{
int flags = pProp->GetFlags();
if ( flags & SPROP_COORD )
{
return pIn->ReadBitCoord();
}
else if ( flags & ( SPROP_COORD_MP | SPROP_COORD_MP_LOWPRECISION | SPROP_COORD_MP_INTEGRAL ) )
{
return pIn->ReadBitCoordMP( (flags >> 15) & 1, (flags >> 14) & 1 );
}
else if ( flags & SPROP_NOSCALE )
{
return pIn->ReadBitFloat();
}
else if ( flags & SPROP_NORMAL )
{
return pIn->ReadBitNormal();
}
else // standard clamped-range float
{
unsigned long dwInterp = pIn->ReadUBitLong(pProp->m_nBits);
float fVal = (float)dwInterp / ((1 << pProp->m_nBits) - 1);
fVal = pProp->m_fLowValue + (pProp->m_fHighValue - pProp->m_fLowValue) * fVal;
return fVal;
}
}
static inline void DecodeVector(SendProp const *pProp, bf_read *pIn, float *v)
{
v[0] = DecodeFloat(pProp, pIn);
v[1] = DecodeFloat(pProp, pIn);
// Don't read in the third component for normals
if ((pProp->GetFlags() & SPROP_NORMAL) == 0)
{
v[2] = DecodeFloat(pProp, pIn);
}
else
{
int signbit = pIn->ReadOneBit();
float v0v0v1v1 = v[0] * v[0] +
v[1] * v[1];
if (v0v0v1v1 < 1.0f)
v[2] = sqrtf( 1.0f - v0v0v1v1 );
else
v[2] = 0.0f;
if (signbit)
v[2] *= -1.0f;
}
}
static inline void DecodeQuaternion(SendProp const *pProp, bf_read *pIn, float *v)
{
v[0] = DecodeFloat(pProp, pIn);
v[1] = DecodeFloat(pProp, pIn);
v[2] = DecodeFloat(pProp, pIn);
v[3] = DecodeFloat(pProp, pIn);
}
int DecodeBits( DecodeInfo *pInfo, unsigned char *pOut )
{
bf_read temp;
// Read the property in (note: we don't return the bits from here because Decode returns
// the decoded bits.. we're interested in getting the encoded bits).
temp = *pInfo->m_pIn;
pInfo->m_pRecvProp = NULL;
pInfo->m_pData = NULL;
g_PropTypeFns[pInfo->m_pProp->m_Type].Decode( pInfo );
// Return the encoded bits.
int nBits = pInfo->m_pIn->GetNumBitsRead() - temp.GetNumBitsRead();
temp.ReadBits(pOut, nBits);
return nBits;
}
// ---------------------------------------------------------------------------------------- //
// Most of the prop types can use this generic FastCopy version. Arrays are a bit of a pain.
// ---------------------------------------------------------------------------------------- //
inline void Generic_FastCopy(
const SendProp *pSendProp,
const RecvProp *pRecvProp,
const unsigned char *pSendData,
unsigned char *pRecvData,
int objectID )
{
// Get the data out of the ent.
CRecvProxyData recvProxyData;
pSendProp->GetProxyFn()(
pSendProp,
pSendData,
pSendData + pSendProp->GetOffset(),
&recvProxyData.m_Value,
0,
objectID
);
// Fill in the data for the recv proxy.
recvProxyData.m_pRecvProp = pRecvProp;
recvProxyData.m_iElement = 0;
recvProxyData.m_ObjectID = objectID;
pRecvProp->GetProxyFn()( &recvProxyData, pRecvData, pRecvData + pRecvProp->GetOffset() );
}
// ---------------------------------------------------------------------------------------- //
// DecodeInfo implementation.
// ---------------------------------------------------------------------------------------- //
void DecodeInfo::CopyVars( const DecodeInfo *pOther )
{
m_pStruct = pOther->m_pStruct;
m_pData = pOther->m_pData;
m_pRecvProp = pOther->m_pRecvProp;
m_pProp = pOther->m_pProp;
m_pIn = pOther->m_pIn;
m_ObjectID = pOther->m_ObjectID;
m_iElement = pOther->m_iElement;
}
// ---------------------------------------------------------------------------------------- //
// Int property type abstraction.
// ---------------------------------------------------------------------------------------- //
void Int_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
int nValue = pVar->m_Int;
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
pOut->WriteVarInt32( nValue );
}
else
{
pOut->WriteSignedVarInt32( nValue );
}
}
else
{
// If signed, preserve lower bits and then re-extend sign if nValue < 0;
// if unsigned, preserve all 32 bits no matter what. Bonus: branchless.
int nPreserveBits = ( 0x7FFFFFFF >> ( 32 - pProp->m_nBits ) );
nPreserveBits |= ( pProp->GetFlags() & SPROP_UNSIGNED ) ? 0xFFFFFFFF : 0;
int nSignExtension = ( nValue >> 31 ) & ~nPreserveBits;
nValue &= nPreserveBits;
nValue |= nSignExtension;
#ifdef DBGFLAG_ASSERT
// Assert that either the property is unsigned and in valid range,
// or signed with a consistent sign extension in the high bits
if ( pProp->m_nBits < 32 )
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
AssertMsg3( nValue == pVar->m_Int, "Unsigned prop %s needs more bits? Expected %i == %i", pProp->GetName(), nValue, pVar->m_Int );
}
else
{
AssertMsg3( nValue == pVar->m_Int, "Signed prop %s needs more bits? Expected %i == %i", pProp->GetName(), nValue, pVar->m_Int );
}
}
else
{
// This should never trigger, but I'm leaving it in for old-time's sake.
Assert( nValue == pVar->m_Int );
}
#endif
pOut->WriteUBitLong( nValue, pProp->m_nBits, false );
}
}
void Int_Decode( DecodeInfo *pInfo )
{
const SendProp *pProp = pInfo->m_pProp;
int flags = pProp->GetFlags();
if ( flags & SPROP_VARINT )
{
if ( flags & SPROP_UNSIGNED )
{
pInfo->m_Value.m_Int = (long)pInfo->m_pIn->ReadVarInt32();
}
else
{
pInfo->m_Value.m_Int = pInfo->m_pIn->ReadSignedVarInt32();
}
}
else
{
int bits = pProp->m_nBits;
pInfo->m_Value.m_Int = pInfo->m_pIn->ReadUBitLong(bits);
if( bits != 32 && (flags & SPROP_UNSIGNED) == 0 )
{
unsigned long highbit = 1ul << (pProp->m_nBits - 1);
if ( pInfo->m_Value.m_Int & highbit )
{
pInfo->m_Value.m_Int -= highbit; // strip high bit...
pInfo->m_Value.m_Int -= highbit; // ... then put it back with sign extension
}
}
}
if ( pInfo->m_pRecvProp )
{
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
}
int Int_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
return p1->ReadVarInt32() != p2->ReadVarInt32();
}
return p1->ReadSignedVarInt32() != p2->ReadSignedVarInt32();
}
return p1->CompareBits(p2, pProp->m_nBits);
}
const char* Int_GetTypeNameString()
{
return "DPT_Int";
}
bool Int_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
return (pVar->m_Int == 0);
}
void Int_DecodeZero( DecodeInfo *pInfo )
{
pInfo->m_Value.m_Int = 0;
if ( pInfo->m_pRecvProp )
{
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
}
bool Int_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
return pIn->ReadVarInt32() == 0;
}
return pIn->ReadSignedVarInt32() == 0;
}
return pIn->ReadUBitLong( pProp->m_nBits ) == 0;
}
void Int_SkipProp( const SendProp *pProp, bf_read *pIn )
{
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
pIn->ReadVarInt32();
}
else
{
pIn->ReadSignedVarInt32();
}
}
else
{
pIn->SeekRelative( pProp->m_nBits );
}
}
// ---------------------------------------------------------------------------------------- //
// Float type abstraction.
// ---------------------------------------------------------------------------------------- //
void Float_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
EncodeFloat( pProp, pVar->m_Float, pOut, objectID );
}
void Float_Decode( DecodeInfo *pInfo )
{
pInfo->m_Value.m_Float = DecodeFloat(pInfo->m_pProp, pInfo->m_pIn);
if ( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
int Float_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
int flags = pProp->GetFlags();
if ( flags & SPROP_COORD )
{
return p1->ReadBitCoordBits() != p2->ReadBitCoordBits();
}
else if ( flags & ( SPROP_COORD_MP | SPROP_COORD_MP_LOWPRECISION | SPROP_COORD_MP_INTEGRAL ) )
{
return p1->ReadBitCoordMPBits( (flags >> 15) & 1, (flags >> 14) & 1 )
!= p2->ReadBitCoordMPBits( (flags >> 15) & 1, (flags >> 14) & 1 );
}
else
{
int bits;
if ( flags & SPROP_NOSCALE )
bits = 32;
else if ( flags & SPROP_NORMAL )
bits = NORMAL_FRACTIONAL_BITS+1;
else
bits = pProp->m_nBits;
return p1->ReadUBitLong( bits ) != p2->ReadUBitLong( bits );
}
}
const char* Float_GetTypeNameString()
{
return "DPT_Float";
}
bool Float_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
return (pVar->m_Float == 0);
}
void Float_DecodeZero( DecodeInfo *pInfo )
{
pInfo->m_Value.m_Float = 0;
if ( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
bool Float_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
return DecodeFloat( pProp, pIn ) == 0.0f;
}
void Float_SkipProp( const SendProp *pProp, bf_read *pIn )
{
// Check for special flags..
if(pProp->GetFlags() & SPROP_COORD)
{
// Read the required integer and fraction flags
unsigned int val = pIn->ReadUBitLong(2);
// this reads two bits, the first bit (bit0 in this word) indicates integer part
// the second bit (bit1 in this word) indicates the fractional part
// If we got either parse them, otherwise it's a zero.
if ( val )
{
// sign bit
int seekDist = 1;
// If there's an integer, read it in
if ( val & 1 )
seekDist += COORD_INTEGER_BITS;
if ( val & 2 )
seekDist += COORD_FRACTIONAL_BITS;
pIn->SeekRelative( seekDist );
}
}
else if ( pProp->GetFlags() & SPROP_COORD_MP )
{
pIn->ReadBitCoordMP( false, false );
}
else if ( pProp->GetFlags() & SPROP_COORD_MP_LOWPRECISION )
{
pIn->ReadBitCoordMP( false, true );
}
else if ( pProp->GetFlags() & SPROP_COORD_MP_INTEGRAL )
{
pIn->ReadBitCoordMP( true, false );
}
else if(pProp->GetFlags() & SPROP_NOSCALE)
{
pIn->SeekRelative( 32 );
}
else if(pProp->GetFlags() & SPROP_NORMAL)
{
pIn->SeekRelative( NORMAL_FRACTIONAL_BITS + 1 );
}
else
{
pIn->SeekRelative( pProp->m_nBits );
}
}
// ---------------------------------------------------------------------------------------- //
// Vector type abstraction.
// ---------------------------------------------------------------------------------------- //
void Vector_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
EncodeFloat(pProp, pVar->m_Vector[0], pOut, objectID);
EncodeFloat(pProp, pVar->m_Vector[1], pOut, objectID);
// Don't write out the third component for normals
if ((pProp->GetFlags() & SPROP_NORMAL) == 0)
{
EncodeFloat(pProp, pVar->m_Vector[2], pOut, objectID);
}
else
{
// Write a sign bit for z instead!
int signbit = (pVar->m_Vector[2] <= -NORMAL_RESOLUTION);
pOut->WriteOneBit( signbit );
}
}
void Vector_Decode(DecodeInfo *pInfo)
{
DecodeVector( pInfo->m_pProp, pInfo->m_pIn, pInfo->m_Value.m_Vector );
if( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
int Vector_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
int c1 = Float_CompareDeltas( pProp, p1, p2 );
int c2 = Float_CompareDeltas( pProp, p1, p2 );
int c3;
if ( pProp->GetFlags() & SPROP_NORMAL )
{
c3 = p1->ReadOneBit() != p2->ReadOneBit();
}
else
{
c3 = Float_CompareDeltas( pProp, p1, p2 );
}
return c1 | c2 | c3;
}
const char* Vector_GetTypeNameString()
{
return "DPT_Vector";
}
bool Vector_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
return ( pVar->m_Vector[0] == 0 ) && ( pVar->m_Vector[1] == 0 ) && ( pVar->m_Vector[2] == 0 );
}
void Vector_DecodeZero( DecodeInfo *pInfo )
{
pInfo->m_Value.m_Vector[0] = 0;
pInfo->m_Value.m_Vector[1] = 0;
pInfo->m_Value.m_Vector[2] = 0;
if ( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
bool Vector_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
float v[3];
DecodeVector( pProp, pIn, v );
return ( v[0] == 0 ) && ( v[1] == 0 ) && ( v[2] == 0 );
}
void Vector_SkipProp( const SendProp *pProp, bf_read *pIn )
{
Float_SkipProp(pProp, pIn);
Float_SkipProp(pProp, pIn);
// Don't read in the third component for normals
if ( pProp->GetFlags() & SPROP_NORMAL )
{
pIn->SeekRelative( 1 );
}
else
{
Float_SkipProp(pProp, pIn);
}
}
// ---------------------------------------------------------------------------------------- //
// VectorXY type abstraction.
// ---------------------------------------------------------------------------------------- //
void VectorXY_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
EncodeFloat(pProp, pVar->m_Vector[0], pOut, objectID);
EncodeFloat(pProp, pVar->m_Vector[1], pOut, objectID);
}
void VectorXY_Decode(DecodeInfo *pInfo)
{
pInfo->m_Value.m_Vector[0] = DecodeFloat(pInfo->m_pProp, pInfo->m_pIn);
pInfo->m_Value.m_Vector[1] = DecodeFloat(pInfo->m_pProp, pInfo->m_pIn);
if( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
int VectorXY_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
int c1 = Float_CompareDeltas( pProp, p1, p2 );
int c2 = Float_CompareDeltas( pProp, p1, p2 );
return c1 | c2;
}
const char* VectorXY_GetTypeNameString()
{
return "DPT_VectorXY";
}
bool VectorXY_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
return ( pVar->m_Vector[0] == 0 ) && ( pVar->m_Vector[1] == 0 );
}
void VectorXY_DecodeZero( DecodeInfo *pInfo )
{
pInfo->m_Value.m_Vector[0] = 0;
pInfo->m_Value.m_Vector[1] = 0;
if ( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
bool VectorXY_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
float v[2];
v[0] = DecodeFloat(pProp, pIn);
v[1] = DecodeFloat(pProp, pIn);
return ( v[0] == 0 ) && ( v[1] == 0 );
}
void VectorXY_SkipProp( const SendProp *pProp, bf_read *pIn )
{
Float_SkipProp(pProp, pIn);
Float_SkipProp(pProp, pIn);
}
#if 0 // We can't ship this since it changes the size of DTVariant to be 20 bytes instead of 16 and that breaks MODs!!!
// ---------------------------------------------------------------------------------------- //
// Quaternion type abstraction.
// ---------------------------------------------------------------------------------------- //
void Quaternion_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
EncodeFloat(pProp, pVar->m_Vector[0], pOut, objectID);
EncodeFloat(pProp, pVar->m_Vector[1], pOut, objectID);
EncodeFloat(pProp, pVar->m_Vector[2], pOut, objectID);
EncodeFloat(pProp, pVar->m_Vector[3], pOut, objectID);
}
void Quaternion_Decode(DecodeInfo *pInfo)
{
DecodeQuaternion( pInfo->m_pProp, pInfo->m_pIn, pInfo->m_Value.m_Vector );
if( pInfo->m_pRecvProp )
{
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
}
int Quaternion_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
int c1 = Float_CompareDeltas( pProp, p1, p2 );
int c2 = Float_CompareDeltas( pProp, p1, p2 );
int c3 = Float_CompareDeltas( pProp, p1, p2 );
int c4 = Float_CompareDeltas( pProp, p1, p2 );
return c1 | c2 | c3 | c4;
}
const char* Quaternion_GetTypeNameString()
{
return "DPT_Quaternion";
}
bool Quaternion_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
return ( pVar->m_Vector[0] == 0 ) && ( pVar->m_Vector[1] == 0 ) && ( pVar->m_Vector[2] == 0 ) && ( pVar->m_Vector[3] == 0 );
}
void Quaternion_DecodeZero( DecodeInfo *pInfo )
{
pInfo->m_Value.m_Vector[0] = 0;
pInfo->m_Value.m_Vector[1] = 0;
pInfo->m_Value.m_Vector[2] = 0;
pInfo->m_Value.m_Vector[3] = 0;
if ( pInfo->m_pRecvProp )
{
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
}
bool Quaternion_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
float v[4];
DecodeQuaternion( pProp, pIn, v );
return ( v[0] == 0 ) && ( v[1] == 0 ) && ( v[2] == 0 ) && ( v[3] == 0 );
}
void Quaternion_SkipProp( const SendProp *pProp, bf_read *pIn )
{
Float_SkipProp(pProp, pIn);
Float_SkipProp(pProp, pIn);
Float_SkipProp(pProp, pIn);
Float_SkipProp(pProp, pIn);
}
#endif
// ---------------------------------------------------------------------------------------- //
// String type abstraction.
// ---------------------------------------------------------------------------------------- //
void String_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
// First count the string length, then do one WriteBits call.
int len;
for ( len=0; len < DT_MAX_STRING_BUFFERSIZE-1; len++ )
{
if( pVar->m_pString[len] == 0 )
{
break;
}
}
// Optionally write the length here so deltas can be compared faster.
pOut->WriteUBitLong( len, DT_MAX_STRING_BITS );
pOut->WriteBits( pVar->m_pString, len * 8 );
}
void String_Decode(DecodeInfo *pInfo)
{
// Read it in.
int len = pInfo->m_pIn->ReadUBitLong( DT_MAX_STRING_BITS );
char *tempStr = pInfo->m_TempStr;
if ( len >= DT_MAX_STRING_BUFFERSIZE )
{
Warning( "String_Decode( %s ) invalid length (%d)\n", pInfo->m_pRecvProp->GetName(), len );
len = DT_MAX_STRING_BUFFERSIZE - 1;
}
pInfo->m_pIn->ReadBits( tempStr, len*8 );
tempStr[len] = 0;
pInfo->m_Value.m_pString = tempStr;
// Give it to the RecvProxy.
if ( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
// Compare the bits in pBuf1 and pBuf2 and return 1 if they are different.
// This must always seek both buffers to wherever they start at + nBits.
static inline int AreBitsDifferent( bf_read *pBuf1, bf_read *pBuf2, int nBits )
{
int nDWords = nBits >> 5;
int diff = 0;
for ( int iDWord=0; iDWord < nDWords; iDWord++ )
{
diff |= (pBuf1->ReadUBitLong(32) != pBuf2->ReadUBitLong(32));
}
int nRemainingBits = nBits - (nDWords<<5);
if (nRemainingBits > 0)
diff |= pBuf1->ReadUBitLong( nRemainingBits ) != pBuf2->ReadUBitLong( nRemainingBits );
return diff;
}
int String_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
int len1 = p1->ReadUBitLong( DT_MAX_STRING_BITS );
int len2 = p2->ReadUBitLong( DT_MAX_STRING_BITS );
if ( len1 == len2 )
{
// check if both strings are empty
if (len1 == 0)
return false;
// Ok, they're short and fast.
return AreBitsDifferent( p1, p2, len1*8 );
}
else
{
p1->SeekRelative( len1 * 8 );
p2->SeekRelative( len2 * 8 );
return true;
}
}
const char* String_GetTypeNameString()
{
return "DPT_String";
}
bool String_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
return ( pVar->m_pString[0] == 0 );
}
void String_DecodeZero( DecodeInfo *pInfo )
{
pInfo->m_Value.m_pString = pInfo->m_TempStr;
pInfo->m_TempStr[0] = 0;
if ( pInfo->m_pRecvProp )
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
bool String_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
// Read it in.
int len = pIn->ReadUBitLong( DT_MAX_STRING_BITS );
pIn->SeekRelative( len*8 );
return len == 0;
}
void String_SkipProp( const SendProp *pProp, bf_read *pIn )
{
int len = pIn->ReadUBitLong( DT_MAX_STRING_BITS );
pIn->SeekRelative( len*8 );
}
// ---------------------------------------------------------------------------------------- //
// Array abstraction.
// ---------------------------------------------------------------------------------------- //
int Array_GetLength( const unsigned char *pStruct, const SendProp *pProp, int objectID )
{
// Get the array length from the proxy.
ArrayLengthSendProxyFn proxy = pProp->GetArrayLengthProxy();
if ( proxy )
{
int nElements = proxy( pStruct, objectID );
// Make sure it's not too big.
if ( nElements > pProp->GetNumElements() )
{
Assert( false );
nElements = pProp->GetNumElements();
}
return nElements;
}
else
{
return pProp->GetNumElements();
}
}
void Array_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
SendProp *pArrayProp = pProp->GetArrayProp();
AssertMsg( pArrayProp, "Array_Encode: missing m_pArrayProp for SendProp '%s'.", pProp->m_pVarName );
int nElements = Array_GetLength( pStruct, pProp, objectID );
// Write the number of elements.
pOut->WriteUBitLong( nElements, pProp->GetNumArrayLengthBits() );
unsigned char *pCurStructOffset = (unsigned char*)pStruct + pArrayProp->GetOffset();
for ( int iElement=0; iElement < nElements; iElement++ )
{
DVariant var;
// Call the proxy to get the value, then encode.
pArrayProp->GetProxyFn()( pArrayProp, pStruct, pCurStructOffset, &var, iElement, objectID );
g_PropTypeFns[pArrayProp->GetType()].Encode( pStruct, &var, pArrayProp, pOut, objectID );
pCurStructOffset += pProp->GetElementStride();
}
}
void Array_Decode( DecodeInfo *pInfo )
{
SendProp *pArrayProp = pInfo->m_pProp->GetArrayProp();
AssertMsg( pArrayProp, ("Array_Decode: missing m_pArrayProp for a property.") );
// Setup a DecodeInfo that is used to decode each of the child properties.
DecodeInfo subDecodeInfo;
subDecodeInfo.CopyVars( pInfo );
subDecodeInfo.m_pProp = pArrayProp;
int elementStride = 0;
ArrayLengthRecvProxyFn lengthProxy = 0;
if ( pInfo->m_pRecvProp )
{
RecvProp *pArrayRecvProp = pInfo->m_pRecvProp->GetArrayProp();
subDecodeInfo.m_pRecvProp = pArrayRecvProp;
// Note we get the OFFSET from the array element property and the STRIDE from the array itself.
subDecodeInfo.m_pData = (char*)pInfo->m_pData + pArrayRecvProp->GetOffset();
elementStride = pInfo->m_pRecvProp->GetElementStride();
Assert( elementStride != -1 ); // (Make sure it was set..)
lengthProxy = pInfo->m_pRecvProp->GetArrayLengthProxy();
}
int nElements = pInfo->m_pIn->ReadUBitLong( pInfo->m_pProp->GetNumArrayLengthBits() );
if ( lengthProxy )
lengthProxy( pInfo->m_pStruct, pInfo->m_ObjectID, nElements );
for ( subDecodeInfo.m_iElement=0; subDecodeInfo.m_iElement < nElements; subDecodeInfo.m_iElement++ )
{
g_PropTypeFns[pArrayProp->GetType()].Decode( &subDecodeInfo );
subDecodeInfo.m_pData = (char*)subDecodeInfo.m_pData + elementStride;
}
}
int Array_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
SendProp *pArrayProp = pProp->GetArrayProp();
AssertMsg( pArrayProp, "Array_CompareDeltas: missing m_pArrayProp for SendProp '%s'.", pProp->m_pVarName );
int nLengthBits = pProp->GetNumArrayLengthBits();
int length1 = p1->ReadUBitLong( nLengthBits );
int length2 = p2->ReadUBitLong( nLengthBits );
int bDifferent = length1 != length2;
// Compare deltas on the props that are the same.
int nSame = min( length1, length2 );
for ( int iElement=0; iElement < nSame; iElement++ )
{
bDifferent |= g_PropTypeFns[pArrayProp->GetType()].CompareDeltas( pArrayProp, p1, p2 );
}
// Now just eat up the remaining properties in whichever buffer was larger.
if ( length1 != length2 )
{
bf_read *buffer = (length1 > length2) ? p1 : p2;
int nExtra = max( length1, length2 ) - nSame;
for ( int iEatUp=0; iEatUp < nExtra; iEatUp++ )
{
SkipPropData( buffer, pArrayProp );
}
}
return bDifferent;
}
void Array_FastCopy(
const SendProp *pSendProp,
const RecvProp *pRecvProp,
const unsigned char *pSendData,
unsigned char *pRecvData,
int objectID )
{
const RecvProp *pArrayRecvProp = pRecvProp->GetArrayProp();
const SendProp *pArraySendProp = pSendProp->GetArrayProp();
CRecvProxyData recvProxyData;
recvProxyData.m_pRecvProp = pArrayRecvProp;
recvProxyData.m_ObjectID = objectID;
// Find out the array length and call the RecvProp's array-length proxy.
int nElements = Array_GetLength( pSendData, pSendProp, objectID );
ArrayLengthRecvProxyFn lengthProxy = pRecvProp->GetArrayLengthProxy();
if ( lengthProxy )
lengthProxy( pRecvData, objectID, nElements );
const unsigned char *pCurSendPos = pSendData + pArraySendProp->GetOffset();
unsigned char *pCurRecvPos = pRecvData + pArrayRecvProp->GetOffset();
for ( recvProxyData.m_iElement=0; recvProxyData.m_iElement < nElements; recvProxyData.m_iElement++ )
{
// Get this array element out of the sender's data.
pArraySendProp->GetProxyFn()( pArraySendProp, pSendData, pCurSendPos, &recvProxyData.m_Value, recvProxyData.m_iElement, objectID );
pCurSendPos += pSendProp->GetElementStride();
// Write it into the receiver.
pArrayRecvProp->GetProxyFn()( &recvProxyData, pRecvData, pCurRecvPos );
pCurRecvPos += pRecvProp->GetElementStride();
}
}
const char* Array_GetTypeNameString()
{
return "DPT_Array";
}
bool Array_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
int nElements = Array_GetLength( pStruct, pProp, -1 );
return ( nElements == 0 );
}
void Array_DecodeZero( DecodeInfo *pInfo )
{
ArrayLengthRecvProxyFn lengthProxy = pInfo->m_pRecvProp->GetArrayLengthProxy();
if ( lengthProxy )
lengthProxy( pInfo->m_pStruct, pInfo->m_ObjectID, 0 );
}
bool Array_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
SendProp *pArrayProp = pProp->GetArrayProp();
AssertMsg( pArrayProp, ("Array_IsEncodedZero: missing m_pArrayProp for a property.") );
int nElements = pIn->ReadUBitLong( pProp->GetNumArrayLengthBits() );
for ( int i=0; i < nElements; i++ )
{
// skip over data
g_PropTypeFns[pArrayProp->GetType()].IsEncodedZero( pArrayProp, pIn );
}
return nElements == 0;;
}
void Array_SkipProp( const SendProp *pProp, bf_read *pIn )
{
SendProp *pArrayProp = pProp->GetArrayProp();
AssertMsg( pArrayProp, ("Array_SkipProp: missing m_pArrayProp for a property.") );
int nElements = pIn->ReadUBitLong( pProp->GetNumArrayLengthBits() );
for ( int i=0; i < nElements; i++ )
{
// skip over data
g_PropTypeFns[pArrayProp->GetType()].SkipProp( pArrayProp, pIn );
}
}
// ---------------------------------------------------------------------------------------- //
// Datatable type abstraction.
// ---------------------------------------------------------------------------------------- //
const char* DataTable_GetTypeNameString()
{
return "DPT_DataTable";
}
// ---------------------------------------------------------------------------------------- //
// Int 64 property type abstraction.
// ---------------------------------------------------------------------------------------- //
void Int64_Encode( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp, bf_write *pOut, int objectID )
{
#ifdef SUPPORTS_INT64
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
pOut->WriteVarInt64( pVar->m_Int64 );
}
else
{
pOut->WriteSignedVarInt32( pVar->m_Int64 );
}
}
else
{
bool bNeg = pVar->m_Int64 < 0;
int64 iCopy = bNeg ? -pVar->m_Int64 : pVar->m_Int64;
uint32 *pInt = (uint32*)&iCopy;
uint32 lowInt = *pInt++;
uint32 highInt = *pInt;
if( pProp->IsSigned() )
{
pOut->WriteOneBit( bNeg );
pOut->WriteUBitLong( (unsigned int)lowInt, 32 );
pOut->WriteUBitLong( (unsigned int)highInt, pProp->m_nBits - 32 - 1 ); // For the sign bit
}
else
{
pOut->WriteUBitLong( (unsigned int)lowInt, 32 );
pOut->WriteUBitLong( (unsigned int)highInt, pProp->m_nBits - 32 );
}
}
#endif
}
void Int64_Decode( DecodeInfo *pInfo )
{
#ifdef SUPPORTS_INT64
if ( pInfo->m_pProp->GetFlags() & SPROP_VARINT )
{
if ( pInfo->m_pProp->GetFlags() & SPROP_UNSIGNED )
{
pInfo->m_Value.m_Int64 = (int64)pInfo->m_pIn->ReadVarInt64();
}
else
{
pInfo->m_Value.m_Int64 = pInfo->m_pIn->ReadSignedVarInt64();
}
}
else
{
uint32 highInt = 0;
uint32 lowInt = 0;
bool bNeg = false;
if(pInfo->m_pProp->IsSigned())
{
bNeg = pInfo->m_pIn->ReadOneBit() != 0;
lowInt = pInfo->m_pIn->ReadUBitLong( 32 );
highInt = pInfo->m_pIn->ReadUBitLong( pInfo->m_pProp->m_nBits - 32 - 1 );
}
else
{
lowInt = pInfo->m_pIn->ReadUBitLong( 32 );
highInt = pInfo->m_pIn->ReadUBitLong( pInfo->m_pProp->m_nBits - 32 );
}
uint32 *pInt = (uint32*)&pInfo->m_Value.m_Int64;
*pInt++ = lowInt;
*pInt = highInt;
if ( bNeg )
{
pInfo->m_Value.m_Int64 = -pInfo->m_Value.m_Int64;
}
}
if ( pInfo->m_pRecvProp )
{
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
#endif
}
int Int64_CompareDeltas( const SendProp *pProp, bf_read *p1, bf_read *p2 )
{
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
return p1->ReadVarInt64() != p2->ReadVarInt64();
}
return p1->ReadSignedVarInt64() != p2->ReadSignedVarInt64();
}
uint32 highInt1 = p1->ReadUBitLong( pProp->m_nBits - 32 );
uint32 lowInt1 = p1->ReadUBitLong( 32 );
uint32 highInt2 = p2->ReadUBitLong( pProp->m_nBits - 32 );
uint32 lowInt2 = p2->ReadUBitLong( 32 );
return highInt1 != highInt2 || lowInt1 != lowInt2;
}
const char* Int64_GetTypeNameString()
{
return "DPT_Int64";
}
bool Int64_IsZero( const unsigned char *pStruct, DVariant *pVar, const SendProp *pProp )
{
#ifdef SUPPORTS_INT64
return (pVar->m_Int64 == 0);
#else
return false;
#endif
}
void Int64_DecodeZero( DecodeInfo *pInfo )
{
#ifdef SUPPORTS_INT64
pInfo->m_Value.m_Int64 = 0;
if ( pInfo->m_pRecvProp )
{
pInfo->m_pRecvProp->GetProxyFn()( pInfo, pInfo->m_pStruct, pInfo->m_pData );
}
#endif
}
bool Int64_IsEncodedZero( const SendProp *pProp, bf_read *pIn )
{
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
return pIn->ReadVarInt64() == 0;
}
return pIn->ReadSignedVarInt64() == 0;
}
uint32 highInt1 = pIn->ReadUBitLong( pProp->m_nBits - 32 );
uint32 lowInt1 = pIn->ReadUBitLong( 32 );
return (highInt1 == 0 && lowInt1 == 0);
}
void Int64_SkipProp( const SendProp *pProp, bf_read *pIn )
{
if ( pProp->GetFlags() & SPROP_VARINT)
{
if ( pProp->GetFlags() & SPROP_UNSIGNED )
{
pIn->ReadVarInt64();
}
else
{
pIn->ReadSignedVarInt64();
}
}
else
{
pIn->SeekRelative( pProp->m_nBits );
}
}
PropTypeFns g_PropTypeFns[DPT_NUMSendPropTypes] =
{
// DPT_Int
{
Int_Encode,
Int_Decode,
Int_CompareDeltas,
Generic_FastCopy,
Int_GetTypeNameString,
Int_IsZero,
Int_DecodeZero,
Int_IsEncodedZero,
Int_SkipProp,
},
// DPT_Float
{
Float_Encode,
Float_Decode,
Float_CompareDeltas,
Generic_FastCopy,
Float_GetTypeNameString,
Float_IsZero,
Float_DecodeZero,
Float_IsEncodedZero,
Float_SkipProp,
},
// DPT_Vector
{
Vector_Encode,
Vector_Decode,
Vector_CompareDeltas,
Generic_FastCopy,
Vector_GetTypeNameString,
Vector_IsZero,
Vector_DecodeZero,
Vector_IsEncodedZero,
Vector_SkipProp,
},
// DPT_VectorXY
{
VectorXY_Encode,
VectorXY_Decode,
VectorXY_CompareDeltas,
Generic_FastCopy,
VectorXY_GetTypeNameString,
VectorXY_IsZero,
VectorXY_DecodeZero,
VectorXY_IsEncodedZero,
VectorXY_SkipProp,
},
// DPT_String
{
String_Encode,
String_Decode,
String_CompareDeltas,
Generic_FastCopy,
String_GetTypeNameString,
String_IsZero,
String_DecodeZero,
String_IsEncodedZero,
String_SkipProp,
},
// DPT_Array
{
Array_Encode,
Array_Decode,
Array_CompareDeltas,
Array_FastCopy,
Array_GetTypeNameString,
Array_IsZero,
Array_DecodeZero,
Array_IsEncodedZero,
Array_SkipProp,
},
// DPT_DataTable
{
NULL,
NULL,
NULL,
NULL,
DataTable_GetTypeNameString,
NULL,
NULL,
NULL,
NULL,
},
#if 0 // We can't ship this since it changes the size of DTVariant to be 20 bytes instead of 16 and that breaks MODs!!!
// DPT_Quaternion
{
Quaternion_Encode,
Quaternion_Decode,
Quaternion_CompareDeltas,
Generic_FastCopy,
Quaternion_GetTypeNameString,
Quaternion_IsZero,
Quaternion_DecodeZero,
Quaternion_IsEncodedZero,
Quaternion_SkipProp,
},
#endif
#ifdef SUPPORTS_INT64
// DPT_Int64
{
Int64_Encode,
Int64_Decode,
Int64_CompareDeltas,
Generic_FastCopy,
Int64_GetTypeNameString,
Int64_IsZero,
Int64_DecodeZero,
Int64_IsEncodedZero,
Int64_SkipProp,
},
#endif
};
|