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
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#include "cbase.h"
#include "econ_item_view.h"
#include "econ_item_system.h"
#include "econ_item_description.h"
#include "econ_item_inventory.h"
#include "rtime.h"
#include "econ_gcmessages.h"
#include "gamestringpool.h"
// For localization
#include "tier3/tier3.h"
#include "vgui/ILocalize.h"
#include "isaverestore.h"
#include "dt_utlvector_send.h"
#include "dt_utlvector_recv.h"
#include <vgui_controls/Panel.h>
#ifdef CLIENT_DLL
#ifndef DEDICATED
#include "vgui/IScheme.h"
#endif
#endif
#if defined(TF_CLIENT_DLL)
#include "tf_duel_summary.h"
#include "econ_contribution.h"
#include "tf_player_info.h"
#include "tf_gcmessages.h"
#include "c_tf_freeaccount.h"
#include "c_tf_player.h"
#endif
#include "materialsystem/itexture.h"
#include "materialsystem/itexturecompositor.h"
#include "activitylist.h"
#ifdef CLIENT_DLL
#include "gc_clientsystem.h"
#endif // CLIENT_DLL
#ifdef GC_DLL
#error "CEconItemView is not meant to be compiled on the GC! There are silent assumptions made about attributes, etc."
#endif // GC_DLL
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#ifdef STAGING_ONLY
ConVar econ_force_style_index( "econ_force_style_index", "-1", FCVAR_REPLICATED );
#endif // STAGING_ONLY
// Networking tables for attributes
BEGIN_NETWORK_TABLE_NOBASE( CEconItemAttribute, DT_ScriptCreatedAttribute )
// Note: we are networking the value as an int, even though it's a "float", because really it isn't
// a float. It's 32 raw bits.
#ifndef CLIENT_DLL
SendPropInt( SENDINFO(m_iAttributeDefinitionIndex), -1, SPROP_UNSIGNED ),
SendPropInt( SENDINFO_NAME(m_flValue, m_iRawValue32), 32, SPROP_UNSIGNED ),
#if ENABLE_ATTRIBUTE_CURRENCY_TRACKING
SendPropInt( SENDINFO(m_nRefundableCurrency), -1, SPROP_UNSIGNED ),
#endif // ENABLE_ATTRIBUTE_CURRENCY_TRACKING
#else
RecvPropInt( RECVINFO(m_iAttributeDefinitionIndex) ),
RecvPropInt( RECVINFO_NAME(m_flValue, m_iRawValue32) ),
RecvPropFloat( RECVINFO(m_flValue), SPROP_NOSCALE ), // for demo compatibility only
#if ENABLE_ATTRIBUTE_CURRENCY_TRACKING
RecvPropInt( RECVINFO(m_nRefundableCurrency) ),
#endif // ENABLE_ATTRIBUTE_CURRENCY_TRACKING
#endif
END_NETWORK_TABLE()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemAttribute::CEconItemAttribute( void )
{
Init();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemAttribute::CEconItemAttribute( const attrib_definition_index_t iAttributeIndex, float flValue )
{
Init();
m_iAttributeDefinitionIndex = iAttributeIndex;
SetValue( flValue );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemAttribute::CEconItemAttribute( const attrib_definition_index_t iAttributeIndex, uint32 unValue )
{
Init();
m_iAttributeDefinitionIndex = iAttributeIndex;
SetIntValue( unValue );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemAttribute::SetValue( float flValue )
{
// Assert( GetStaticData() && GetStaticData()->IsStoredAsFloat() );
m_flValue = flValue;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemAttribute::SetIntValue( uint32 unValue )
{
// @note we don't check the storage type here, because this is how it is set from the data file
// Note that numbers approaching two billion cannot be stored in a float
// representation because they will map to NaNs. Numbers below 16 million
// will fail if denormals are disabled.
m_flValue = *(float*)&unValue;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemAttribute::Init( void )
{
m_iAttributeDefinitionIndex = INVALID_ATTRIB_DEF_INDEX;
m_flValue = 0.0f;
#if ENABLE_ATTRIBUTE_CURRENCY_TRACKING
m_nRefundableCurrency = 0;
#endif // ENABLE_ATTRIBUTE_CURRENCY_TRACKING
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemAttribute::operator=( const CEconItemAttribute &val )
{
m_iAttributeDefinitionIndex = val.m_iAttributeDefinitionIndex;
m_flValue = val.m_flValue;
#if ENABLE_ATTRIBUTE_CURRENCY_TRACKING
m_nRefundableCurrency = val.m_nRefundableCurrency;
#endif // ENABLE_ATTRIBUTE_CURRENCY_TRACKING
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const CEconItemAttributeDefinition *CEconItemAttribute::GetStaticData( void ) const
{
return GetItemSchema()->GetAttributeDefinition( m_iAttributeDefinitionIndex );
}
BEGIN_NETWORK_TABLE_NOBASE( CAttributeList, DT_AttributeList )
#if !defined( CLIENT_DLL )
SendPropUtlVectorDataTable( m_Attributes, MAX_ATTRIBUTES_PER_ITEM, DT_ScriptCreatedAttribute ),
#else
RecvPropUtlVectorDataTable( m_Attributes, MAX_ATTRIBUTES_PER_ITEM, DT_ScriptCreatedAttribute ),
#endif // CLIENT_DLL
END_NETWORK_TABLE()
BEGIN_DATADESC_NO_BASE( CAttributeList )
END_DATADESC()
//===========================================================================================================================
// SCRIPT CREATED ITEMS
//===========================================================================================================================
BEGIN_NETWORK_TABLE_NOBASE( CEconItemView, DT_ScriptCreatedItem )
#if !defined( CLIENT_DLL )
SendPropInt( SENDINFO( m_iItemDefinitionIndex ), 20, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iEntityLevel ), 8 ),
//SendPropInt( SENDINFO( m_iItemID ), 64, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iItemIDHigh ), 32, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iItemIDLow ), 32, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iAccountID ), 32, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iEntityQuality ), 5 ),
SendPropBool( SENDINFO( m_bInitialized ) ),
SendPropBool( SENDINFO( m_bOnlyIterateItemViewAttributes) ),
SendPropDataTable(SENDINFO_DT(m_AttributeList), &REFERENCE_SEND_TABLE(DT_AttributeList)),
SendPropInt( SENDINFO( m_iTeamNumber ) ),
SendPropDataTable(SENDINFO_DT( m_NetworkedDynamicAttributesForDemos ), &REFERENCE_SEND_TABLE( DT_AttributeList ) ),
#else
RecvPropInt( RECVINFO( m_iItemDefinitionIndex ) ),
RecvPropInt( RECVINFO( m_iEntityLevel ) ),
//RecvPropInt( RECVINFO( m_iItemID ) ),
RecvPropInt( RECVINFO( m_iItemIDHigh ) ),
RecvPropInt( RECVINFO( m_iItemIDLow ) ),
RecvPropInt( RECVINFO( m_iAccountID ) ),
RecvPropInt( RECVINFO( m_iEntityQuality ) ),
RecvPropBool( RECVINFO( m_bInitialized ) ),
RecvPropBool( RECVINFO( m_bOnlyIterateItemViewAttributes ) ),
RecvPropDataTable(RECVINFO_DT(m_AttributeList), 0, &REFERENCE_RECV_TABLE(DT_AttributeList)),
RecvPropInt( RECVINFO( m_iTeamNumber ) ),
RecvPropDataTable( RECVINFO_DT( m_NetworkedDynamicAttributesForDemos ), 0, &REFERENCE_RECV_TABLE( DT_AttributeList ) ),
#endif // CLIENT_DLL
END_NETWORK_TABLE()
BEGIN_DATADESC_NO_BASE( CEconItemView )
DEFINE_FIELD( m_iItemDefinitionIndex, FIELD_INTEGER ),
DEFINE_FIELD( m_iEntityQuality, FIELD_INTEGER ),
DEFINE_FIELD( m_iEntityLevel, FIELD_INTEGER ),
DEFINE_FIELD( m_iItemID, FIELD_INTEGER ),
// DEFINE_FIELD( m_wszItemName, FIELD_STRING ), Regenerated post-save
// DEFINE_FIELD( m_szItemName, FIELD_STRING ), Regenerated post-save
// DEFINE_FIELD( m_szAttributeDescription, FIELD_STRING ), Regenerated post-save
// m_AttributeLineColors // Regenerated post-save
// m_Attributes // Custom handling in Save()/Restore()
DEFINE_FIELD( m_bInitialized, FIELD_BOOLEAN ),
DEFINE_FIELD( m_bOnlyIterateItemViewAttributes, FIELD_BOOLEAN ),
DEFINE_EMBEDDED( m_AttributeList ),
DEFINE_EMBEDDED( m_NetworkedDynamicAttributesForDemos ),
END_DATADESC()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemView::CEconItemView( void )
{
m_iItemDefinitionIndex = INVALID_ITEM_DEF_INDEX;
m_iEntityQuality = (int)AE_UNDEFINED;
m_iEntityLevel = 0;
SetItemID( INVALID_ITEM_ID );
m_iInventoryPosition = 0;
m_bInitialized = false;
m_bOnlyIterateItemViewAttributes = false;
m_iAccountID = 0;
m_pNonSOEconItem = NULL;
m_bColorInit = false;
m_bPaintOverrideInit = false;
m_bHasPaintOverride = false;
m_flOverrideIndex = 0.f;
#if defined( CLIENT_DLL )
m_bIsTradeItem = false;
m_iEntityQuantity = 1;
m_unClientFlags = 0;
m_unOverrideStyle = INVALID_STYLE_INDEX;
m_unOverrideOrigin = kEconItemOrigin_Max;
#endif
#if BUILD_ITEM_NAME_AND_DESC
m_pDescription = NULL;
m_pszGrayedOutReason = NULL;
#endif
#ifdef CLIENT_DLL
m_pWeaponSkinBase = NULL;
m_pWeaponSkinBaseCompositor = NULL;
m_iLastGeneratedTeamSkin = TF_TEAM_RED;
m_bWeaponSkinUseHighRes = false;
m_bWeaponSkinUseLowRes = false;
#endif // CLIENT_DLL
m_iTeamNumber = TF_TEAM_RED;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemView::~CEconItemView( void )
{
#ifdef CLIENT_DLL
SafeRelease( &m_pWeaponSkinBase );
SafeRelease( &m_pWeaponSkinBaseCompositor );
#endif // CLIENT_DLL
DestroyAllAttributes();
#if BUILD_ITEM_NAME_AND_DESC
MarkDescriptionDirty();
free( m_pszGrayedOutReason );
#endif
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemView::CEconItemView( const CEconItemView &src )
{
#if BUILD_ITEM_NAME_AND_DESC
m_pDescription = NULL;
m_pszGrayedOutReason = NULL;
#endif
#ifdef CLIENT_DLL
// Need to null these out here for initial behavior.
m_pWeaponSkinBase = NULL;
m_pWeaponSkinBaseCompositor = NULL;
m_nWeaponSkinGeneration = 0;
m_iLastGeneratedTeamSkin = TF_TEAM_RED;
m_unWeaponSkinBaseCreateFlags = 0;
m_bWeaponSkinUseHighRes = src.m_bWeaponSkinUseHighRes;
m_bWeaponSkinUseLowRes = src.m_bWeaponSkinUseLowRes;
#endif //CLIENT_DLL
m_iTeamNumber = src.m_iTeamNumber; // keep the same team from the first creation
*this = src;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::Init( int iDefIndex, int iQuality, int iLevel, uint32 iAccountID )
{
m_AttributeList.Init();
m_NetworkedDynamicAttributesForDemos.Init();
m_iItemDefinitionIndex = iDefIndex;
CEconItemDefinition *pData = GetStaticData();
if ( !pData )
{
// We've got an item that we don't have static data for.
return;
}
SetItemID( INVALID_ITEM_ID );
m_bInitialized = true;
m_iAccountID = iAccountID;
if ( iQuality == AE_USE_SCRIPT_VALUE )
{
m_iEntityQuality = pData->GetQuality();
// Kyle says: this is a horrible hack because AE_UNDEFINED will get stuffed into a uint8 when
// loaded into the item definition, but then read back out into a regular int here.
if ( m_iEntityQuality == (uint8)AE_UNDEFINED )
{
m_iEntityQuality = (int)AE_NORMAL;
}
}
else if ( iQuality == k_unItemQuality_Any )
{
m_iEntityQuality = (int)AE_RARITY1;
}
else
{
m_iEntityQuality = iQuality;
}
if ( iLevel == AE_USE_SCRIPT_VALUE )
{
m_iEntityLevel = pData->RollItemLevel();
}
else
{
m_iEntityLevel = iLevel;
}
// We made changes to quality, level, etc. so mark the description as dirty.
MarkDescriptionDirty();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItemView& CEconItemView::operator=( const CEconItemView& src )
{
m_iItemDefinitionIndex = src.m_iItemDefinitionIndex;
m_iEntityQuality = src.m_iEntityQuality;
m_iEntityLevel = src.m_iEntityLevel;
SetItemID( src.GetItemID() );
m_iInventoryPosition = src.m_iInventoryPosition;
m_bInitialized = src.m_bInitialized;
m_bOnlyIterateItemViewAttributes = src.m_bOnlyIterateItemViewAttributes;
m_iAccountID = src.m_iAccountID;
SetNonSOEconItem(src.m_pNonSOEconItem);
m_bColorInit = false; // reset Color init
m_bPaintOverrideInit = false;
m_bHasPaintOverride = false;
m_flOverrideIndex = 0.f;
#ifdef CLIENT_DLL
m_iLastGeneratedTeamSkin = src.m_iLastGeneratedTeamSkin;
m_bIsTradeItem = src.m_bIsTradeItem;
m_iEntityQuantity = src.m_iEntityQuantity;
m_unClientFlags = src.m_unClientFlags;
m_unOverrideStyle = src.m_unOverrideStyle;
m_unOverrideOrigin = src.m_unOverrideOrigin;
SafeAssign( &m_pWeaponSkinBase, src.m_pWeaponSkinBase );
SafeAssign( &m_pWeaponSkinBaseCompositor, src.m_pWeaponSkinBaseCompositor );
m_nWeaponSkinGeneration = src.m_nWeaponSkinGeneration;
m_unWeaponSkinBaseCreateFlags = src.m_unWeaponSkinBaseCreateFlags;
m_bWeaponSkinUseHighRes = src.m_bWeaponSkinUseHighRes;
m_bWeaponSkinUseLowRes = src.m_bWeaponSkinUseLowRes;
#endif // CLIENT_DLL
m_iTeamNumber = src.m_iTeamNumber; // keep the same team from the first creation
DestroyAllAttributes();
m_AttributeList = src.m_AttributeList;
m_NetworkedDynamicAttributesForDemos = src.m_NetworkedDynamicAttributesForDemos;
// TODO: Copying the description pointer and refcounting it would work also.
MarkDescriptionDirty();
// Clear out any overrides we currently have, they'll get reset up on demand.
ResetMaterialOverrides();
return *this;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CEconItemView::operator==( const CEconItemView &other ) const
{
if ( IsValid() != other.IsValid() )
return false;
if ( ( GetItemID() != INVALID_ITEM_ID || other.GetItemID() != INVALID_ITEM_ID ) && GetItemID() != other.GetItemID() )
return false;
if ( GetItemDefIndex() != other.GetItemDefIndex() )
return false;
return true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
GameItemDefinition_t *CEconItemView::GetStaticData( void ) const
{
CEconItemDefinition *pRet = GetItemSchema()->GetItemDefinition( m_iItemDefinitionIndex );
GameItemDefinition_t *pTypedRet = dynamic_cast<GameItemDefinition_t *>( pRet );
AssertMsg( pRet == pTypedRet, "Item definition of inappropriate type." );
return pTypedRet;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int32 CEconItemView::GetQuality() const
{
return GetSOCData()
? GetSOCData()->GetQuality()
#ifdef TF_CLIENT_DLL
: GetFlags() & kEconItemFlagClient_StoreItem
? AE_UNIQUE
#endif
: GetOrigin() != kEconItemOrigin_Invalid
? GetItemQuality()
: AE_NORMAL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
style_index_t CEconItemView::GetStyle() const
{
return GetItemStyle();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
uint8 CEconItemView::GetFlags() const
{
uint8 unSOCFlags = GetSOCData() ? GetSOCData()->GetFlags() : 0;
#if !defined( GAME_DLL )
return unSOCFlags | m_unClientFlags;
#else // defined( GAME_DLL )
return unSOCFlags;
#endif // !defined( GAME_DLL )
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
eEconItemOrigin CEconItemView::GetOrigin() const
{
#ifdef CLIENT_DLL
if( m_unOverrideOrigin != kEconItemOrigin_Max )
{
return m_unOverrideOrigin;
}
#endif//CLIENT_DLL
return GetSOCData() ? GetSOCData()->GetOrigin() : kEconItemOrigin_Invalid;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CEconItemView::GetQuantity() const
{
return GetItemQuantity();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *CEconItemView::GetCustomName() const
{
return GetSOCData() ? GetSOCData()->GetCustomName() : NULL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *CEconItemView::GetCustomDesc() const
{
return GetSOCData() ? GetSOCData()->GetCustomDesc() : NULL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::IterateAttributes( class IEconItemAttributeIterator *pIterator ) const
{
Assert( pIterator );
// Note if we have network attribs, because m_NetworkedDynamicAttributesForDemos might be the iterator
// which we're about to fill up below.
const bool bHasNetworkedAttribsForDemos = m_NetworkedDynamicAttributesForDemos.GetNumAttributes() > 0;
// First, we iterate over the attributes we have local copies of. If we have any attribute
// values here they'll override whatever values we would otherwise have pulled from our
// definition/CEconItem.
const CAttributeList *pAttrList = GetAttributeList();
if ( pAttrList )
{
pAttrList->IterateAttributes( pIterator );
}
if ( m_bOnlyIterateItemViewAttributes )
return;
// This wraps any other iterator class and will prevent double iteration of any attributes
// that exist on us.
class CEconItemAttributeIterator_EconItemViewWrapper : public IEconItemAttributeIterator
{
public:
CEconItemAttributeIterator_EconItemViewWrapper( const CEconItemView *pEconItemView, IEconItemAttributeIterator *pIterator )
: m_pEconItemView( pEconItemView )
, m_pIterator( pIterator )
{
Assert( m_pEconItemView );
Assert( m_pIterator );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, attrib_value_t value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, float value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const uint64& value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_String& value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_DynamicRecipeComponent& value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_ItemSlotCriteria& value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_WorldItemPlacement& value )
{
Assert( pAttrDef );
return m_pEconItemView->GetAttributeList()->GetAttributeByID( pAttrDef->GetDefinitionIndex() )
? true
: m_pIterator->OnIterateAttributeValue( pAttrDef, value );
}
private:
const CEconItemView *m_pEconItemView;
IEconItemAttributeIterator *m_pIterator;
};
CEconItemAttributeIterator_EconItemViewWrapper iteratorWrapper( this, pIterator );
// Next, iterate over our database-backed item if we have one... if we do have a DB
// backing for our item here, that will also feed in the definition attributes.
CEconItem *pEconItem = GetSOCData();
if ( pEconItem )
{
pEconItem->IterateAttributes( &iteratorWrapper );
}
else if ( GetItemID() != INVALID_ITEM_ID && bHasNetworkedAttribsForDemos )
{
// Since there's no persistent data available, try the networked values!
// note: only copies the default type and floats
m_NetworkedDynamicAttributesForDemos.IterateAttributes( &iteratorWrapper );
}
// If we didn't have a DB backing, we can still iterate over our item definition
// attributes ourselves. This can happen if we're previewing an item in the store, etc.
else if ( GetStaticData() )
{
GetStaticData()->IterateAttributes( &iteratorWrapper );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::EnsureDescriptionIsBuilt() const
{
#if BUILD_ITEM_NAME_AND_DESC
if ( m_pDescription )
{
return;
}
m_pDescription = new CEconItemDescription;
IEconItemDescription::YieldingFillOutEconItemDescription( m_pDescription, GLocalizationProvider(), this );
// We use the empty string to mean "grey out but don't specify a user-facing reason".
if ( m_pszGrayedOutReason && m_pszGrayedOutReason[0] )
{
m_pDescription->AddEmptyDescLine();
m_pDescription->LocalizedAddDescLine( GLocalizationProvider(), m_pszGrayedOutReason, ATTRIB_COL_NEGATIVE, kDescLineFlag_Misc );
}
#endif
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::MarkDescriptionDirty()
{
#if BUILD_ITEM_NAME_AND_DESC
if ( m_pDescription )
{
delete m_pDescription;
m_pDescription = NULL;
}
#endif
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::SetGrayedOutReason( const char *pszGrayedOutReason )
{
#if BUILD_ITEM_NAME_AND_DESC
if ( m_pszGrayedOutReason )
{
free( m_pszGrayedOutReason );
m_pszGrayedOutReason = NULL;
}
if ( pszGrayedOutReason )
{
m_pszGrayedOutReason = strdup(pszGrayedOutReason);
}
MarkDescriptionDirty();
#endif
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CEconItemView::GetItemQuantity() const
{
CEconItem *pSOCData = GetSOCData();
if ( pSOCData )
{
return pSOCData->GetQuantity();
}
#ifdef CLIENT_DLL
return m_iEntityQuantity;
#else
return 1;
#endif
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
style_index_t CEconItemView::GetItemStyle() const
{
#ifdef STAGING_ONLY
if ( econ_force_style_index.GetInt() != -1 )
return econ_force_style_index.GetInt();
#endif // STAGING_ONLY
#ifdef CLIENT_DLL
// Are we overriding the backing store style?
if ( m_unOverrideStyle != INVALID_STYLE_INDEX )
return m_unOverrideStyle;
#endif // CLIENT_DLL
static CSchemaAttributeDefHandle pAttrDef_ItemStyleOverride( "item style override" );
float fStyleOverride = 0.f;
if ( FindAttribute_UnsafeBitwiseCast<attrib_value_t>( this, pAttrDef_ItemStyleOverride, &fStyleOverride ) )
{
return fStyleOverride;
}
static CSchemaAttributeDefHandle pAttrDef_ItemStyleStrange( "style changes on strange level" );
uint32 iMaxStyle = 0;
if ( pAttrDef_ItemStyleStrange && FindAttribute( pAttrDef_ItemStyleStrange, &iMaxStyle ) )
{
// Use the strange prefix if the weapon has one.
uint32 unScore = 0;
if ( !FindAttribute( GetKillEaterAttr_Score( 0 ), &unScore ) )
return 0;
// What type of event are we tracking and how does it describe itself?
uint32 unKillEaterEventType = 0;
// This will overwrite our default 0 value if we have a value set but leave it if not.
float fKillEaterEventType;
if ( FindAttribute_UnsafeBitwiseCast<attrib_value_t>( this, GetKillEaterAttr_Type( 0 ), &fKillEaterEventType ) )
{
unKillEaterEventType = fKillEaterEventType;
}
const char *pszLevelingDataName = GetItemSchema()->GetKillEaterScoreTypeLevelingDataName( unKillEaterEventType );
if ( !pszLevelingDataName )
{
pszLevelingDataName = KILL_EATER_RANK_LEVEL_BLOCK_NAME;
}
const CItemLevelingDefinition *pLevelDef = GetItemSchema()->GetItemLevelForScore( pszLevelingDataName, unScore );
if ( !pLevelDef )
return 0;
return Min( pLevelDef->GetLevel(), iMaxStyle );
}
CEconItem *pSOCData = GetSOCData();
if ( pSOCData )
return pSOCData->GetStyle();
return INVALID_STYLE_INDEX;
}
#ifdef CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::SetClientItemFlags( uint8 unFlags )
{
// Generally speaking, we have two uses for client flags:
//
// - we don't have a backing store (a real CEconItem) but want to pretend we do
// for purposes of generating tooltips, graying out icons, etc.
//
// - we may or may not have a backing store but want to shove client-specific
// information into the structure -- things like "this is the item being
// actively previewed", etc.
//
// If neither of these two cases is true, then we're going to get unexpected
// behavior where the GC and the client disagree about the item flags and then
// Terrible Things happen. We assert to make sure we're in one of the above cases.
Assert( !GetSOCData() || (unFlags & kEconItemFlags_CheckFlags_AllGCFlags) == 0 );
m_unClientFlags = unFlags;
MarkDescriptionDirty();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::SetItemStyleOverride( style_index_t unNewStyleOverride )
{
// We should only ever override the style on items that don't have a real
// backing store or we'll start getting disagreements about what the client
// wants to happen and what's being stored on the GC. Unfortunately we can't
// assert on this because we do it sometimes when previewing items.
//Assert( !GetSOCData() );
m_unOverrideStyle = unNewStyleOverride;
MarkDescriptionDirty();
}
void CEconItemView::SetItemOriginOverride( eEconItemOrigin unNewOriginOverride )
{
Assert( !GetSOCData() || m_pNonSOEconItem );
Assert( unNewOriginOverride >= kEconItemOrigin_Invalid );
Assert( unNewOriginOverride <= kEconItemOrigin_Max ); // Allow max. We ignore this value if it's max
m_unOverrideOrigin = unNewOriginOverride;
}
#endif // CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CEconItem *CEconItemView::GetSOCData( void ) const
{
if ( m_pNonSOEconItem )
return m_pNonSOEconItem;
#ifdef CLIENT_DLL
// We need to find the inventory that contains this item. If we're not connected
// to a server, and the owner is the same as the local player, use the local inventory.
// We need to do this for trading, since we are subscribed to the other person's cache.
if ( !engine->IsInGame() && InventoryManager()->GetLocalInventory()->GetOwner().GetAccountID() == m_iAccountID )
return InventoryManager()->GetLocalInventory()->GetSOCDataForItem( GetItemID() );
#endif // CLIENT_DLL
// We're in-game. Find the inventory with our account ID.
CPlayerInventory *pInventory = InventoryManager()->GetInventoryForAccount( m_iAccountID );
if ( pInventory )
return pInventory->GetSOCDataForItem( GetItemID() );
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose: Return the model to use for model panels containing this item
//-----------------------------------------------------------------------------
const char *CEconItemView::GetInventoryModel( void )
{
if ( !GetStaticData() )
return NULL;
return GetStaticData()->GetInventoryModel();
}
//-----------------------------------------------------------------------------
// Purpose: Return the image to use for model panels containing this item
//-----------------------------------------------------------------------------
const char *CEconItemView::GetInventoryImage( void )
{
if ( !GetStaticData() )
return NULL;
// Do we have a style set?
const char* pStyleImage = NULL;
if ( GetStaticData()->GetNumStyles() )
pStyleImage = GetStaticData()->GetStyleInventoryImage( GetItemStyle() );
if ( pStyleImage && *pStyleImage )
return pStyleImage;
return GetStaticData()->GetInventoryImage();
}
//-----------------------------------------------------------------------------
// Purpose: Return the drawing data for the image to use for model panels containing this item
//-----------------------------------------------------------------------------
bool CEconItemView::GetInventoryImageData( int *iPosition, int *iSize )
{
if ( !GetStaticData() )
return false;
for ( int i = 0; i < 2; i++ )
{
iPosition[i] = GetStaticData()->GetInventoryImagePosition(i);
iSize[i] = GetStaticData()->GetInventoryImageSize(i);
}
return true;
}
//-----------------------------------------------------------------------------
// Purpose: Return the image to use for model panels containing this item
//-----------------------------------------------------------------------------
const char *CEconItemView::GetInventoryOverlayImage( int idx )
{
if ( !GetStaticData() )
return NULL;
return GetStaticData()->GetInventoryOverlayImage( idx );
}
int CEconItemView::GetInventoryOverlayImageCount( void )
{
if ( !GetStaticData() )
return 0;
return GetStaticData()->GetInventoryOverlayImageCount();
}
//-----------------------------------------------------------------------------
// Purpose: Return the model to use when displaying this model on the player character model, if any
//-----------------------------------------------------------------------------
const char *CEconItemView::GetPlayerDisplayModel( int iClass, int iTeam ) const
{
const CEconItemDefinition *pDef = GetStaticData();
if ( !pDef )
return NULL;
// If we have styles, give the style system a chance to change the mesh used for this
// player class.
if ( pDef->GetNumStyles() )
{
style_index_t unStyle = GetItemStyle();
const CEconStyleInfo *pStyle = pDef->GetStyleInfo( unStyle );
// It's possible to get back a NULL pStyle if GetItemStyle() returns INVALID_STYLE_INDEX.
if ( pStyle )
{
#if defined( TF_DLL ) || defined( TF_CLIENT_DLL )
// TF styles support per-class models.
const CTFStyleInfo *pTFStyle = assert_cast<const CTFStyleInfo *>( pStyle );
if ( pTFStyle->GetPlayerDisplayModel( iClass, iTeam ) )
return pTFStyle->GetPlayerDisplayModel( iClass, iTeam );
#endif // defined( TF_DLL ) || defined( TF_CLIENT_DLL )
if ( pStyle->GetBasePlayerDisplayModel() )
return pStyle->GetBasePlayerDisplayModel();
}
}
#if defined( TF_DLL ) || defined( TF_CLIENT_DLL )
// If we don't have a style, we still a couple potential overrides.
if ( iClass >= 0 && iClass < LOADOUT_COUNT )
{
// We don't support overriding meshes in the visuals section, but we might still be overriding
// the model for each class at the schema level.
const CTFItemDefinition *pTFDef = dynamic_cast<const CTFItemDefinition *>( pDef );
if ( pTFDef )
{
const char *pszModel = pTFDef->GetPlayerDisplayModel(iClass);
if ( pszModel && pszModel[0] )
return pszModel;
}
}
#endif // defined( TF_DLL ) || defined( TF_CLIENT_DLL )
return pDef->GetBasePlayerDisplayModel();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CEconItemView::GetSkin( int iTeam, bool bViewmodel /*= false*/ ) const
{
int iDefaultSkin = -1;
#ifndef CSTRIKE_DLL
// Immediately abort if we're out of range.
if ( iTeam < 0 || iTeam >= TEAM_VISUAL_SECTIONS )
return 0;
// Do we have a style set?
if ( GetStaticData()->GetNumStyles() )
return GetStaticData()->GetStyleSkin( GetItemStyle(), iTeam, bViewmodel );
iTeam = GetStaticData()->GetBestVisualTeamData( iTeam );
if ( iTeam < 0 || iTeam >= TEAM_VISUAL_SECTIONS )
return -1;
// Do we have per-team skins set?
const perteamvisuals_t *pVisData = GetStaticData()->GetPerTeamVisual( iTeam );
if ( pVisData )
return pVisData->iSkin;
iDefaultSkin = GetItemDefinition()->GetDefaultSkin();
#endif
// Fallback case.
return iDefaultSkin;
}
#ifdef CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose: Handle assignment for textures, which involves some reference counting shenanigans.
//-----------------------------------------------------------------------------
void CEconItemView::SetWeaponSkinBase( ITexture* pBaseTex )
{
SafeAssign( &m_pWeaponSkinBase, pBaseTex );
}
//-----------------------------------------------------------------------------
// Purpose: Handle assignment for compositors, which involves some reference counting shenanigans.
//-----------------------------------------------------------------------------
void CEconItemView::SetWeaponSkinBaseCompositor( ITextureCompositor * pTexCompositor )
{
SafeAssign( &m_pWeaponSkinBaseCompositor, pTexCompositor );
}
//-----------------------------------------------------------------------------
// Purpose: Cancels a pending composite, if one is currently in process.
//-----------------------------------------------------------------------------
void CEconItemView::CancelWeaponSkinComposite( )
{
SafeRelease( &m_pWeaponSkinBaseCompositor );
}
#endif // CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *CEconItemView::GetWorldDisplayModel() const
{
CEconItemDefinition *pData = GetStaticData();
if ( !pData )
return NULL;
return pData->GetWorldDisplayModel();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *CEconItemView::GetExtraWearableModel() const
{
CEconItemDefinition *pData = GetStaticData();
if ( !pData )
return NULL;
return pData->GetExtraWearableModel();
}
const char *CEconItemView::GetExtraWearableViewModel() const
{
CEconItemDefinition *pData = GetStaticData();
if ( !pData )
return NULL;
return pData->GetExtraWearableViewModel();
}
const char *CEconItemView::GetVisionFilteredDisplayModel() const
{
CEconItemDefinition *pData = GetStaticData();
if ( !pData )
return NULL;
return pData->GetVisionFilteredDisplayModel();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CEconItemView::GetQualityParticleType() const
{
static CSchemaParticleHandle pSparkleSystem( "community_sparkle" );
CEconItem* pItem = GetSOCData();
if ( !pItem )
return 0;
if( GetSOCData()->GetQuality() == AE_SELFMADE || GetSOCData()->GetQuality() == AE_COMMUNITY )
return pSparkleSystem ? pSparkleSystem->nSystemID : 0;
else
return 0;
}
//-----------------------------------------------------------------------------
// Purpose: Return the animation set that this item wants the player to use (ie., melee, item1, pda)
//-----------------------------------------------------------------------------
int CEconItemView::GetAnimationSlot( void ) const
{
if ( !GetStaticData() )
return -1;
#if defined( CSTRIKE_DLL ) || defined( DOTA_DLL )
return -1;
#else
return GetStaticData()->GetAnimSlot();
#endif
}
//-----------------------------------------------------------------------------
// Purpose: Return an int that indicates whether the item should be dropped from a dead owner.
//-----------------------------------------------------------------------------
int CEconItemView::GetDropType( void )
{
if ( !GetStaticData() )
return 0;
return GetStaticData()->GetDropType();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::DestroyAllAttributes( void )
{
m_AttributeList.DestroyAllAttributes();
m_NetworkedDynamicAttributesForDemos.DestroyAllAttributes();
NetworkStateChanged();
MarkDescriptionDirty();
}
extern const char *g_EffectTypes[NUM_EFFECT_TYPES];
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
#ifdef CLIENT_DLL
const wchar_t *CEconItemView::GetItemName() const
{
static const wchar_t *pwzDefaultName = L"";
const CEconItemDescription *pDescription = GetDescription();
if ( !pDescription )
return pwzDefaultName;
const econ_item_description_line_t *pNameDescLine = pDescription->GetFirstLineWithMetaType( kDescLineFlag_Name );
if ( !pNameDescLine )
return pwzDefaultName;
return pNameDescLine->sText.Get();
}
//-----------------------------------------------------------------------------
void CEconItemView::GetRenderBounds( Vector& mins, Vector& maxs )
{
const CEconItemDefinition *pDef = GetStaticData();
if ( !pDef )
return;
int iClass = 0;
int iTeam = 0;
#ifdef TF_CLIENT_DLL
C_TFPlayer *pTFPlayer = ToTFPlayer( GetPlayerByAccountID( GetAccountID() ) );
if ( pTFPlayer )
{
iClass = pTFPlayer->GetPlayerClass()->GetClassIndex();
iTeam = pTFPlayer->GetTeamNumber();
}
#endif // TF_CLIENT_DLL
const char * pszModel = GetPlayerDisplayModel( iClass, iTeam );
if ( !pszModel )
return;
int iIndex = modelinfo->GetModelIndex( pszModel );
if ( iIndex == -1 )
{
// hard load the model to get its bounds
MDLHandle_t hMDLFindResult = g_pMDLCache->FindMDL( pszModel );
MDLHandle_t hMDL = pszModel ? hMDLFindResult : MDLHANDLE_INVALID;
if ( g_pMDLCache->IsErrorModel( hMDL ) )
return;
const studiohdr_t * pStudioHdr = g_pMDLCache->GetStudioHdr( hMDL );
VectorCopy( pStudioHdr->hull_min, mins );
VectorCopy( pStudioHdr->hull_max, maxs );
g_pMDLCache->Release( hMDLFindResult );
}
else
{
const model_t *pModel = modelinfo->GetModel( iIndex );
modelinfo->GetModelRenderBounds( pModel, mins, maxs );
}
}
#endif
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconItemView::InitNetworkedDynamicAttributesForDemos( void )
{
if ( !GetSOCData() )
return;
class CEconDynamicAttributesForDemosIterator : public CEconItemSpecificAttributeIterator
{
public:
CEconDynamicAttributesForDemosIterator( CAttributeList* out_NetworkedDynamicAttributesForDemos )
: m_NetworkedDynamicAttributesForDemos( out_NetworkedDynamicAttributesForDemos )
{
m_bAdded = false;
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, attrib_value_t value ) OVERRIDE
{
CEconItemAttribute attribute( pAttrDef->GetDefinitionIndex(), value );
m_NetworkedDynamicAttributesForDemos->AddAttribute( &attribute );
m_bAdded = true;
return true;
}
virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, float value ) OVERRIDE
{
CEconItemAttribute attribute( pAttrDef->GetDefinitionIndex(), value );
m_NetworkedDynamicAttributesForDemos->AddAttribute( &attribute );
m_bAdded = true;
return true;
}
bool BAdded( void ){ return m_bAdded; }
private:
bool m_bAdded;
CAttributeList *m_NetworkedDynamicAttributesForDemos;
};
m_NetworkedDynamicAttributesForDemos.DestroyAllAttributes();
CEconDynamicAttributesForDemosIterator it( &m_NetworkedDynamicAttributesForDemos );
IterateAttributes( &it );
if ( it.BAdded() )
{
NetworkStateChanged();
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
static int RemapOverridePaintIndexToRGB( uint32 unIndex, uint32 unTeamIndex )
{
enum { kSamplePoints = 256, };
static uint32 k_unWitchYellow[] = {
5328971, 5328971, 5328971, 5328971, 5328971, 5328971, 5328971, 5328971,
5328971, 5328971, 5395018, 5591625, 5723465, 5855050, 5921095, 6052679,
6315591, 6447429, 6513222, 6710852, 7039299, 7170884, 7433793, 7631425,
7894336, 8222784, 8354622, 8618045, 8815420, 9078333, 9406779, 9604411,
9802040, 10064952, 10328376, 10459959, 10722870, 11051318, 11314483, 11511859,
11709490, 11841074, 12103729, 12301360, 12498479, 12630063, 12761901, 12959022,
13090604, 13156651, 13288236, 13485099, 13616683, 13682474, 13748010, 13813801,
13945386, 13945386, 14011433, 14011433, 14011433, 13945386, 13945386, 13879594,
13814314, 13813801, 13748010, 13682474, 13616681, 13616683, 13550890, 13550890,
13354027, 13288234, 13288236, 13222443, 13222443, 13156651, 13156651, 13025322,
13025324, 12959531, 12893740, 12893740, 12893740, 12762413, 12696621, 12696621,
12630828, 12630574, 12630574, 12499760, 12433713, 12433713, 12367922, 12302642,
12302387, 12236596, 12236598, 12171575, 12105528, 12039736, 11908409, 11974204,
11908413, 11842880, 11842880, 11842880, 11908421, 11776837, 11645765, 11579973,
11579975, 11514182, 11448137, 11382344, 11316298, 11184712, 11053387, 11053387,
10921802, 10855755, 10724941, 10659150, 10658896, 10527311, 10527057, 10395986,
10330195, 10264147, 10264147, 10264149, 10263895, 10198104, 10132313, 10198106,
10132058, 10263133, 10263133, 10328928, 10394721, 10394723, 10328675, 10394981,
10460263, 10526056, 10329190, 10394983, 10329188, 10394723, 10328928, 10328926,
10526042, 10526040, 10394452, 10459985, 10394446, 10460235, 10525511, 10525763,
10657089, 10657341, 10723131, 10854456, 10920502, 11183156, 11380273, 11512111,
11906350, 12038190, 12301100, 12629804, 12827436, 13221676, 13419306, 13616170,
13813803, 13945386, 14077226, 13879593, 13813801, 13616170, 13485099, 13221674,
12893227, 12630057, 12301098, 12103723, 11775018, 11511594, 11117353, 10853929,
10459431, 10130984, 9868327, 9670182, 9472807, 9275686, 9013027, 8815396,
8618019, 8420385, 8289569, 8223006, 8026399, 7894813, 7763484, 7829020,
7763738, 7894810, 7960857, 8158234, 8552475, 8684059, 8881690, 9079324,
9210908, 9407772, 9605405, 9671198, 9736989, 9736989, 9736991, 9605918,
9473565, 9341979, 9078809, 8684059, 8355096, 7763224, 7434010, 6973206,
6447895, 6118679, 5723416, 5394715, 5131549, 5000483, 5000234, 4999981,
5000242, 4999990, 4868407, 4671291, 4539707, 4539709, 4605502, 4671041,
4868420, 5000006, 5065799, 5131592, 5197385, 5263178, 5328971, 5263178,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unWitchYellow ) == kSamplePoints );
static uint32 k_unDistinctiveLackOfSanity[] =
{
5720667, 5720667, 5786460, 5720667, 5786460, 5786460, 5851996, 5851741,
6048606, 6048606, 6114145, 6114145, 6245474, 6311013, 6311013, 6441829,
6507624, 6573417, 6704491, 6704491, 6704493, 6901359, 6901359, 7097970,
7097970, 7163252, 7229045, 7294840, 7425656, 7491449, 7622523, 7688062,
7819137, 7950209, 8147077, 8277894, 8409226, 8540301, 8540303, 8671376,
8737171, 8737171, 8867985, 8671376, 8671374, 8540301, 8475019, 8475273,
8278408, 8147334, 8082309, 7885441, 7819902, 7754366, 7754621, 7558012,
7492217, 7426937, 7361142, 7164533, 7164531, 7164529, 7033456, 6967663,
6902382, 6836587, 6771564, 6771564, 6639978, 6574185, 6640232, 6508903,
6443110, 6574439, 6443110, 6442599, 6442599, 6573415, 6508392, 6573417,
6507624, 6572905, 6572905, 6572907, 6638187, 6703212, 6768494, 6834289,
6965105, 6964850, 7030132, 7029621, 7226486, 7160439, 7225720, 7356538,
7421820, 7421820, 7487102, 7617920, 7617921, 7748226, 7814021, 7879303,
7944328, 7944330, 8074635, 8271500, 8271246, 8336527, 8336529, 8598420,
8532629, 8597911, 8794521, 8859803, 8859803, 8990878, 9121440, 9120928,
9317793, 9317539, 9382823, 9448103, 9513898, 9644714, 9709995, 9840813,
9840815, 9906095, 9971890, 9971378, 10102194, 10167989, 10233269, 10364085,
10364087, 10363833, 10429369, 10429114, 10560186, 10625725, 10625468, 10691007,
10691007, 10756543, 10756289, 10756289, 10756289, 10756289, 10691007, 10625214,
10625468, 10559932, 10560186, 10429114, 10363576, 10298040, 10232501, 10101429,
10101683, 9970608, 9970608, 9773998, 9773998, 9642923, 9511848, 9511848,
9381030, 9381030, 9249956, 9053345, 8987806, 8922270, 8856731, 8725656,
8594839, 8463510, 8397971, 8201360, 8070287, 8070285, 7939211, 7807625,
7676805, 7545732, 7479937, 7283582, 7152508, 7086972, 6890361, 6759029,
6627700, 6496882, 6366064, 6300269, 6169194, 6103399, 5840997, 5775716,
5513312, 5448030, 5251162, 5054551, 5054806, 4857684, 4661073, 4595534,
4398666, 4267337, 4136776, 4070981, 4005186, 3874111, 3677502, 3480634,
3414840, 3283767, 3152951, 3152949, 3153203, 3153203, 3153460, 3153460,
3219253, 3285046, 3350839, 3416632, 3482425, 3614011, 3811133, 3942465,
4008260, 4336455, 4533321, 4664908, 4730701, 4993362, 5124948, 5256536,
5650013, 5781599, 6044003, 6175589, 6306920, 6504042, 6701167, 6898035,
7029621, 7292279, 7489404, 7686526, 7752064, 8014722, 8080261, 8277127,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unDistinctiveLackOfSanity ) == kSamplePoints );
static uint32 k_unOverabundanceOfRottingFlesh[] =
{
12703514, 12703514, 12703514, 12703516, 12703516, 12703514, 12572700, 12506907,
12506907, 12506652, 12506907, 12506907, 12506652, 12506652, 12506907, 12506652,
12506652, 12506652, 12506654, 12506654, 12440861, 12441374, 12441374, 12375581,
12375581, 12375583, 12375583, 12375583, 12375583, 12309536, 12309536, 12309536,
12309536, 12309537, 12112928, 12243744, 12243744, 12177697, 12046881, 12046881,
11981090, 11915299, 11915299, 11915044, 11915044, 11849253, 11783206, 11783206,
11717415, 11717417, 11651624, 11585576, 11519785, 11519787, 11453994, 11388460,
11387948, 11256621, 11190830, 11190832, 11124785, 11058993, 11058995, 10992948,
10992950, 10861364, 10795572, 10729527, 10729527, 10663736, 10597690, 10466106,
10466106, 10465852, 10400062, 10334015, 10202431, 10202433, 10136640, 10136385,
10004801, 10004803, 10004549, 9938243, 10004037, 9938244, 9938246, 9872199,
9937478, 9937224, 9871431, 9871433, 9871433, 9805640, 9870921, 9805128,
9805128, 9805128, 9805128, 9805128, 9739337, 9804360, 9804360, 9804360,
9804360, 9804360, 9869640, 9869640, 9803847, 9803847, 9803847, 9803847,
9738054, 9803334, 9737541, 9672261, 9672261, 9672261, 9606468, 9606470,
9606470, 9540677, 9475397, 9475397, 9409604, 9409604, 9212739, 9212741,
9212741, 9146948, 9081668, 9081668, 8950596, 8950596, 9015875, 9015875,
9081668, 9081668, 9081664, 8950850, 8950848, 8885568, 8819775, 8951359,
8950846, 9016894, 9016892, 9016892, 9016890, 9147962, 9016376, 9147958,
9082165, 9213494, 9081907, 9147698, 9147698, 9278768, 9212975, 9212973,
9212716, 9278508, 9212713, 9212456, 9343272, 9212454, 9343524, 9343011,
9277218, 9408034, 9342241, 9407523, 9341730, 9341730, 9341219, 9275426,
9406242, 9339938, 9339938, 9339171, 9273380, 9272613, 9272613, 9141030,
9206310, 9140519, 9140265, 9205290, 9138985, 9138985, 9138987, 9073453,
9007662, 9007150, 9007150, 9137968, 9072945, 8941618, 9138484, 9007413,
9138999, 9204788, 9270581, 9205556, 9271604, 9272115, 9469490, 9404210,
9536049, 9536817, 9603119, 9734960, 9866542, 9801772, 9999147, 9999913,
10197288, 10263848, 10264613, 10462244, 10462754, 10463776, 10661152, 10792988,
10859547, 10991642, 11057688, 11190040, 11256086, 11388435, 11520274, 11521042,
11652625, 11784463, 11784974, 11916813, 11916813, 11982604, 12048397, 12114188,
12179981, 12246028, 12246028, 12311308, 12311308, 12311308, 12311308, 12377101,
12377101, 12377101, 12377101, 12377101, 12377101, 12377101, 12377101, 12377101,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unOverabundanceOfRottingFlesh ) == kSamplePoints );
// orange_flash
static uint32 k_unTheFlamesBelow[] =
{
11548953, 11614745, 11746074, 11877659, 12008987, 12140572, 12337693, 12469278,
12666655, 12863776, 13060897, 13258274, 13455395, 13652772, 13849893, 14047014,
14244391, 14375976, 14573097, 14704681, 14836010, 14967595, 15033387, 15164716,
15164972, 15230508, 15230508, 15230508, 15164716, 15033387, 14967595, 14836010,
14638889, 14507304, 14310183, 14112806, 13915685, 13718308, 13455651, 13258274,
13060897, 12863776, 12666399, 12469278, 12272157, 12075036, 11943451, 11811866,
11680538, 11614745, 11548953, 11548953, 11548953, 11614745, 11680538, 11746330,
11877659, 12009244, 12206364, 12403485, 12600862, 12797983, 12995360, 13192482,
13389859, 13652772, 13849893, 14047270, 14244391, 14441512, 14638889, 14770474,
14901802, 15033387, 15099179, 15164972, 15230508, 15230508, 15098924, 14835755,
14572586, 14177832, 13783078, 13322789, 12862755, 12468001, 12139295, 11811101,
11614491, 11548954, 11549209, 11747351, 12011542, 12407317, 12869139, 13396754,
13924369, 14451983, 14979598, 15506957, 15902989, 16298508, 16562443, 16759819,
16760075, 16562188, 16166669, 15704590, 15110927, 14451217, 13791507, 13132053,
12538390, 12011032, 11681049, 11548953, 11614745, 11812888, 12142615, 12538646,
13066005, 13593875, 14187538, 14780944, 15308815, 15836430, 16232204, 16561932,
16694283, 16760075, 16561932, 16100621, 15506958, 14846992, 14121490, 13395732,
12670486, 12142359, 11746585, 11548953, 11614745, 11812632, 12076824, 12472343,
12934165, 13395988, 13923859, 14517265, 15044880, 15506702, 15968269, 16298508,
16562187, 16759819, 16760075, 16627979, 16298508, 15902733, 15375374, 14781967,
14188560, 13594897, 13066771, 12539156, 12077334, 11747351, 11549209, 11548954,
11680028, 11876637, 12139295, 12533793, 12928291, 13323045, 13783335, 14178088,
14572586, 14836011, 15098924, 15230508, 15230508, 15164972, 15099179, 15033387,
14901802, 14770474, 14638889, 14441768, 14244391, 14047270, 13849893, 13652772,
13455395, 13192482, 12995360, 12797983, 12600862, 12403485, 12206364, 12074780,
11877659, 11746330, 11680538, 11614745, 11548953, 11548953, 11548953, 11614745,
11680538, 11811866, 11943451, 12075036, 12272157, 12403742, 12600863, 12863776,
13060897, 13258274, 13455395, 13718308, 13915685, 14112806, 14310183, 14507304,
14638889, 14836010, 14967339, 15033387, 15164716, 15230508, 15230508, 15230508,
15164972, 15164716, 15033387, 14967595, 14836010, 14704681, 14573097, 14375976,
14244391, 14047014, 13849893, 13652772, 13455395, 13258274, 13060897, 12863776,
12666655, 12469278, 12337693, 12140572, 12008987, 11877659, 11746074, 11614745,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unTheFlamesBelow ) == kSamplePoints );
// green_pulse
static uint32 k_unThatQueesyFeeling[] =
{
7439904, 7571489, 7703329, 7900706, 8032547, 8295716, 8493349, 8756518,
9019943, 9283369, 9546794, 9810219, 10073644, 10402606, 10666031, 10929200,
11192625, 11390259, 11653428, 11851061, 12048437, 12180278, 12312119, 12443703,
12509496, 12575288, 12575288, 12509496, 12443703, 12312119, 12180278, 11982901,
11785268, 11522099, 11258674, 10995249, 10731823, 10468398, 10139181, 9810219,
9546794, 9217576, 8954151, 8690726, 8427557, 8229924, 7966755, 7834914,
7637537, 7571488, 7440160, 7439904, 7439904, 7505696, 7637281, 7769121,
7900962, 8098339, 8361508, 8624933, 8888359, 9151784, 9415209, 9744171,
10073388, 10336814, 10666031, 10929456, 11192882, 11456051, 11719476, 11982645,
12114486, 12311863, 12443447, 12509496, 12575288, 12575288, 12509496, 12443703,
12311863, 12180278, 11982645, 11785012, 11521843, 11258674, 10995249, 10731823,
10402862, 10139181, 9810219, 9546794, 9283368, 8954151, 8690982, 8427557,
8229924, 8032291, 7834914, 7703073, 7571489, 7505696, 7439904, 7439904,
7505696, 7571745, 7703329, 7900706, 8098083, 8295716, 8559141, 8822310,
9085736, 9349161, 9678378, 9941804, 10270765, 10534447, 10863408, 11126833,
11390258, 11653428, 11851061, 12048694, 12246070, 12377911, 12509240, 12575288,
12575288, 12575288, 12509240, 12377911, 12246070, 12048694, 11851061, 11653428,
11390258, 11126833, 10863408, 10534447, 10270765, 9941804, 9678378, 9349161,
9085736, 8822310, 8559141, 8295716, 8098083, 7900706, 7703329, 7571745,
7505696, 7439904, 7439904, 7505696, 7571489, 7703073, 7834914, 8032291,
8229924, 8427557, 8690982, 8954151, 9283368, 9546794, 9810219, 10139181,
10402862, 10731823, 10995249, 11258674, 11521843, 11785012, 11982645, 12180278,
12311863, 12443703, 12509496, 12575288, 12575288, 12509496, 12443447, 12311863,
12180022, 11982645, 11719476, 11521843, 11258418, 10929456, 10666031, 10336814,
10073388, 9744427, 9480745, 9151784, 8888359, 8624933, 8361508, 8163875,
7900962, 7769121, 7637281, 7505696, 7439904, 7439904, 7440160, 7571488,
7637537, 7834914, 7966755, 8164132, 8427557, 8690726, 8954151, 9217576,
9546538, 9810219, 10139181, 10402606, 10731823, 10995249, 11258674, 11521843,
11785268, 11982645, 12180278, 12312119, 12443703, 12509496, 12575288, 12575288,
12509496, 12443703, 12312119, 12180278, 12048437, 11851061, 11653428, 11390259,
11192625, 10929200, 10666031, 10402606, 10073644, 9810219, 9546794, 9283369,
9019943, 8756518, 8493349, 8295716, 8032547, 7900706, 7703329, 7571489,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unThatQueesyFeeling ) == kSamplePoints );
// blue_pulse
static uint32 k_unBubbleBubble[] =
{
9094364, 9160156, 9291485, 9357278, 9488607, 9685472, 9816801, 10013922,
10145251, 10342372, 10539237, 10736358, 10933479, 11130345, 11327466, 11458795,
11655916, 11852781, 11984366, 12115695, 12247024, 12378352, 12444145, 12509681,
12575474, 12641010, 12641010, 12575474, 12509681, 12444145, 12312816, 12181487,
12049902, 11853037, 11655916, 11458795, 11261930, 11064808, 10802151, 10605030,
10407908, 10211043, 10013922, 9816801, 9619936, 9488607, 9357022, 9225693,
9160156, 9094364, 9094364, 9094364, 9159900, 9225693, 9357022, 9553886,
9751008, 9948129, 10210786, 10473444, 10736102, 11064551, 11392745, 11655659,
11983853, 12312303, 12640496, 12903410, 13166068, 13494262, 13691383, 13954040,
14150905, 14282490, 14413819, 14545148, 14545148, 14545148, 14545148, 14413819,
14282490, 14151162, 13954040, 13756919, 13494262, 13231604, 12968947, 12706289,
12377839, 12115181, 11786732, 11458538, 11195880, 10867430, 10604773, 10342115,
10079458, 9816800, 9619679, 9422814, 9291485, 9160156, 9094364, 9094364,
9094364, 9094364, 9160157, 9291485, 9422814, 9554143, 9685472, 9882593,
10079458, 10276579, 10473701, 10736358, 10933479, 11130345, 11327466, 11590123,
11787245, 11918574, 12115695, 12247024, 12378352, 12509681, 12575218, 12641010,
12641010, 12641010, 12575218, 12509681, 12378352, 12247024, 12115695, 11918574,
11787245, 11590123, 11327466, 11130345, 10933479, 10736358, 10473701, 10276579,
10079458, 9882593, 9685472, 9554143, 9422814, 9291485, 9160157, 9094364,
9094364, 9094364, 9094364, 9160156, 9291485, 9422814, 9619679, 9816800,
10079458, 10342115, 10604773, 10867430, 11195880, 11458538, 11786732, 12115181,
12377839, 12706289, 12968947, 13231604, 13494262, 13756919, 13954040, 14151162,
14282490, 14413819, 14545148, 14545148, 14545148, 14545148, 14413819, 14282490,
14150905, 13954040, 13691383, 13494262, 13231604, 12903410, 12640497, 12312303,
11983853, 11721195, 11392745, 11064551, 10801638, 10473444, 10210786, 9948129,
9751008, 9553887, 9357022, 9225693, 9159900, 9094364, 9094364, 9094364,
9160156, 9225693, 9357022, 9488351, 9619935, 9816801, 10013922, 10210787,
10407908, 10605030, 10802151, 11064808, 11261674, 11458795, 11655916, 11853037,
12049902, 12181231, 12312560, 12443889, 12575217, 12641010, 12641010, 12641010,
12575474, 12575217, 12509681, 12378352, 12247024, 12115695, 11984366, 11852781,
11655916, 11524331, 11327466, 11130345, 10933479, 10736358, 10539237, 10342372,
10145251, 10013922, 9816801, 9685472, 9554143, 9422814, 9291485, 9160156,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unBubbleBubble ) == kSamplePoints );
// purple_orange_rand
static uint32 k_unAfraidOfShadowsDark[] =
{
4536928, 4536928, 4602721, 4602721, 4668515, 4668515, 4734308, 4734308,
4734308, 4734309, 4734309, 4734309, 4865896, 4865896, 4931689, 4931689,
4997226, 4997226, 5063019, 5063019, 5128813, 5194606, 5194607, 5260400,
5260400, 5391730, 5457523, 5457524, 5457524, 5523317, 5589111, 5654904,
5654905, 5654905, 5720698, 5852028, 5917821, 5917822, 5983615, 5983615,
6115202, 6115202, 6115203, 6180996, 6312326, 6378119, 6378120, 6443913,
6444683, 6576785, 6577556, 6709913, 6710941, 6843555, 6844583, 6845868,
6912945, 6914230, 6915515, 6982592, 6983877, 6985161, 6986446, 6987986,
6989014, 6924762, 6926046, 6926817, 6862308, 6863079, 6863593, 6798827,
6799597, 6799083, 6929385, 6863079, 6927845, 6992866, 7057632, 7187677,
7252442, 7382487, 7447251, 7577296, 7641805, 7772362, 7836871, 7967172,
8097473, 8227774, 8292283, 8422841, 8487607, 8749750, 8814516, 8879794,
8945072, 9075888, 8946614, 8752575, 8427464, 8102353, 7842008, 7647197,
7582176, 7842777, 8233938, 8559562, 8950979, 9277117, 9537977, 9733814,
9734070, 9734070, 9734070, 9734070, 9734071, 9799863, 9799863, 9799863,
9799863, 9799863, 9799863, 9799863, 9799863, 9799604, 9799863, 9799604,
9799344, 9733548, 9733032, 9732771, 9732509, 9731992, 9731473, 9731211,
9796485, 9861502, 9861239, 9926256, 10057321, 10122338, 10253403, 10450004,
10580557, 10777414, 10974016, 11235897, 11432754, 11629612, 11825958, 12088353,
12350747, 12547606, 12875538, 13072654, 13203723, 13531656, 13729032, 13729032,
13794568, 13991688, 14188808, 14254344, 14385672, 14451464, 14648328, 14845704,
14977032, 15108360, 15239689, 15436809, 15568393, 15831050, 15962892, 16160781,
16226832, 16293140, 16294170, 16294943, 16295713, 16296229, 16297257, 16363566,
16364595, 16365365, 16431930, 16432957, 16433729, 16500037, 16501065, 16501836,
16502864, 16503634, 16569685, 16570712, 16571482, 16637789, 16638303, 16639072,
16639586, 16640355, 16640869, 16707173, 16707430, 16707943, 16708456, 16708712,
16709224, 16775016, 16775272, 16775784, 16776040, 16776552, 16776295, 16776551,
16776551, 16776039, 16709991, 16709736, 16709224, 16511336, 16247913, 16116074,
15786858, 15457899, 15193963, 14865004, 14601837, 14206573, 13811822, 13351022,
12890479, 12429935, 11969392, 11508591, 11048049, 10587504, 10192752, 9732208,
9337455, 8877166, 8482670, 8153453, 7758957, 7430252, 7101291, 6772586,
6509418, 6246505, 5983337, 5786216, 5588840, 5391719, 5194599, 5063014,
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_unAfraidOfShadowsDark ) == kSamplePoints );
static uint32 *k_pPointSampleContent_Team0[] =
{
&k_unWitchYellow[0],
&k_unDistinctiveLackOfSanity[0],
&k_unOverabundanceOfRottingFlesh[0],
&k_unTheFlamesBelow[0],
&k_unThatQueesyFeeling[0],
&k_unAfraidOfShadowsDark[0],
};
static uint32 *k_pPointSampleContent_Team1[] =
{
&k_unWitchYellow[0],
&k_unDistinctiveLackOfSanity[0],
&k_unOverabundanceOfRottingFlesh[0],
&k_unBubbleBubble[0],
&k_unThatQueesyFeeling[0],
&k_unAfraidOfShadowsDark[0],
};
COMPILE_TIME_ASSERT( ARRAYSIZE( k_pPointSampleContent_Team0 ) == ARRAYSIZE( k_pPointSampleContent_Team1 ) );
if ( unIndex >= ARRAYSIZE( k_pPointSampleContent_Team0 ) )
return 0;
if ( unTeamIndex > 1 )
return 0;
const float fScaledTime = gpGlobals->curtime * 22.0f; // arbitrary time scalar people liked
const unsigned int unSamplePoint0 = (unsigned int)fScaledTime % kSamplePoints;
const unsigned int unSamplePoint1 = (unSamplePoint0 + 1) % kSamplePoints;
const float fDelta = fScaledTime - (unsigned int)fScaledTime; // offset between two sample points for blending
const uint32 *punData = (unTeamIndex == 0 ? k_pPointSampleContent_Team0 : k_pPointSampleContent_Team1)[unIndex];
Color c0;
c0.SetRawColor( punData[unSamplePoint0] );
Color c1;
c1.SetRawColor( punData[unSamplePoint1] );
const Color cBlend( Lerp( fDelta, c0.r(), c1.r() ),
Lerp( fDelta, c0.g(), c1.g() ),
Lerp( fDelta, c0.b(), c1.b() ) );
return cBlend.GetRawColor();
}
//-----------------------------------------------------------------------------
// Purpose: Get RGB modifying attribute value
//-----------------------------------------------------------------------------
int CEconItemView::GetModifiedRGBValue( bool bAltColor )
{
enum
{
kPaintConstant_Default = 0,
kPaintConstant_OldTeamColor = 1,
};
static CSchemaAttributeDefHandle pAttr_Paint( "set item tint rgb" );
static CSchemaAttributeDefHandle pAttr_Paint2( "set item tint rgb 2" );
static CSchemaAttributeDefHandle pAttr_PaintOverride( "SPELL: set item tint RGB" );
// Do we have an override paint color? This takes precedence over base paints and team
// paints.
#if defined( TF_DLL ) || defined( TF_CLIENT_DLL )
extern bool TF_IsHolidayActive( /*EHoliday*/ int eHoliday );
if ( TF_IsHolidayActive( kHoliday_HalloweenOrFullMoon ) )
#endif // defined( TF_DLL ) || defined( TF_CLIENT_DLL )
{
if ( !m_bPaintOverrideInit )
{
m_bHasPaintOverride = FindAttribute_UnsafeBitwiseCast<attrib_value_t>( this, pAttr_PaintOverride, &m_flOverrideIndex );
m_bPaintOverrideInit = true;
}
if ( m_bHasPaintOverride )
return RemapOverridePaintIndexToRGB( (uint32)m_flOverrideIndex, bAltColor ? 1 : 0 );
}
if ( !m_bColorInit )
{
// See if we also have a secondary paint color.
uint32 unRGB = kPaintConstant_Default;
uint32 unRGBAlt = kPaintConstant_Default;
float fRGB;
float fRGBAlt;
// If we have no base paint color we don't do anything special.
if ( FindAttribute_UnsafeBitwiseCast<attrib_value_t>( this, pAttr_Paint, &fRGB ) )
{
unRGB = (uint32)fRGB;
unRGBAlt = unRGB;
}
// Backwards compatibility for old team colored items.
if ( unRGB == kPaintConstant_OldTeamColor )
{
unRGB = RGB_INT_RED;
unRGBAlt = RGB_INT_BLUE;
}
else if ( FindAttribute_UnsafeBitwiseCast<attrib_value_t>( this, pAttr_Paint2, &fRGBAlt ) )
{
unRGBAlt = (uint32)fRGBAlt;
}
else
{
// By default our secondary color will match our primary if we can't find a replacement.
unRGBAlt = unRGB;
}
m_unRGB = unRGB;
m_unAltRGB = unRGBAlt;
m_bColorInit = true;
}
return bAltColor ? m_unAltRGB : m_unRGB;
}
uint64 CEconItemView::GetCustomUserTextureID()
{
static CSchemaAttributeDefHandle pAttr_CustomTextureLo( "custom texture lo" );
static CSchemaAttributeDefHandle pAttr_CustomTextureHi( "custom texture hi" );
uint32 unLowVal, unHighVal;
const bool bHasLowVal = FindAttribute( pAttr_CustomTextureLo, &unLowVal ),
bHasHighVal = FindAttribute( pAttr_CustomTextureHi, &unHighVal );
// We should have both, or neither. We should never have just one
Assert( bHasLowVal == bHasHighVal );
if ( bHasLowVal && bHasHighVal )
{
return ((uint64)unHighVal << 32) | (uint64)unLowVal;
}
// No attribute set
return 0;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CAttributeList::CAttributeList()
{
m_pManager = NULL;
m_Attributes.Purge();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::SetManager( CAttributeManager *pManager )
{
m_pManager = pManager;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::Init()
{
m_Attributes.Purge();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::IterateAttributes( class IEconItemAttributeIterator *pIterator ) const
{
Assert( pIterator );
FOR_EACH_VEC( m_Attributes, i )
{
const CEconItemAttribute *pAttrInst = &m_Attributes[i];
const CEconItemAttributeDefinition *pAttrDef = pAttrInst->GetStaticData();
if ( !pAttrDef )
continue;
const ISchemaAttributeType *pAttrType = pAttrDef->GetAttributeType();
Assert( pAttrType );
Assert( pAttrType->BSupportsGameplayModificationAndNetworking() );
// We know (and assert) that we only need 32 bits of data to store this attribute
// data. We don't know anything about the type but we'll let the type handle it
// below.
attribute_data_union_t value;
value.asFloat = pAttrInst->m_flValue;
if ( !pAttrType->OnIterateAttributeValue( pIterator, pAttrDef, value ) )
return;
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::DestroyAllAttributes( void )
{
if ( m_Attributes.Count() )
{
m_Attributes.Purge();
NotifyManagerOfAttributeValueChanges();
NetworkStateChanged();
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::AddAttribute( CEconItemAttribute *pAttribute )
{
Assert( pAttribute );
// Only add attributes to the attribute list if they have a definition we can
// pull data from.
if ( !pAttribute->GetStaticData() )
return;
m_Attributes.AddToTail( *pAttribute );
NetworkStateChanged();
NotifyManagerOfAttributeValueChanges();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::SetRuntimeAttributeValue( const CEconItemAttributeDefinition *pAttrDef, float flValue )
{
Assert( pAttrDef );
// Look for an existing attribute.
const int iAttributes = GetNumAttributes();
for ( int i = 0; i < iAttributes; i++ )
{
CEconItemAttribute *pAttribute = GetAttribute(i);
if ( pAttribute->GetAttribIndex() == pAttrDef->GetDefinitionIndex() )
{
// Found existing attribute -- change value.
pAttribute->m_flValue = flValue;
NotifyManagerOfAttributeValueChanges();
return;
}
}
// Couldn't find an existing attribute for this definition -- make a new one.
CEconItemAttribute attribute;
attribute.m_iAttributeDefinitionIndex = pAttrDef->GetDefinitionIndex();
attribute.m_flValue = flValue;
m_Attributes.AddToTail( attribute );
NotifyManagerOfAttributeValueChanges();
}
#if ENABLE_ATTRIBUTE_CURRENCY_TRACKING
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::SetRuntimeAttributeRefundableCurrency( const CEconItemAttributeDefinition *pAttrDef, int iRefundableCurrency )
{
Assert( pAttrDef );
// Look for an existing attribute.
const int iAttributes = GetNumAttributes();
for ( int i = 0; i < iAttributes; i++ )
{
CEconItemAttribute *pAttribute = GetAttribute(i);
if ( pAttribute->GetAttribIndex() == pAttrDef->GetDefinitionIndex() )
{
// Found existing attribute -- change value.
pAttribute->m_nRefundableCurrency = iRefundableCurrency;
return;
}
}
AssertMsg1( false, "Unable to find attribute '%s' for setting currency!", pAttrDef->GetDefinitionName() );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CAttributeList::GetRuntimeAttributeRefundableCurrency( const CEconItemAttributeDefinition *pAttrDef ) const
{
const int iAttributes = GetNumAttributes();
for ( int i = 0; i < iAttributes; i++ )
{
const CEconItemAttribute *pAttribute = GetAttribute(i);
if ( pAttribute->GetAttribIndex() == pAttrDef->GetDefinitionIndex() )
return pAttribute->m_nRefundableCurrency;
}
AssertMsg1( false, "Unable to find attribute '%s' for getting currency!", pAttrDef->GetDefinitionName() );
return 0;
}
#endif // ENABLE_ATTRIBUTE_CURRENCY_TRACKING
//-----------------------------------------------------------------------------
// Purpose: Remove an attribute by name
//-----------------------------------------------------------------------------
void CAttributeList::RemoveAttribute( const CEconItemAttributeDefinition *pAttrDef )
{
const int iAttributes = m_Attributes.Count();
for ( int i = 0; i < iAttributes; i++ )
{
if ( m_Attributes[i].GetStaticData() == pAttrDef )
{
m_Attributes.Remove( i );
NotifyManagerOfAttributeValueChanges();
return;
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Remove an attribute by index
//-----------------------------------------------------------------------------
void CAttributeList::RemoveAttributeByIndex( int iIndex )
{
if ( iIndex < 0 || iIndex >= GetNumAttributes() )
return;
m_Attributes.Remove( iIndex );
NotifyManagerOfAttributeValueChanges();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const CEconItemAttribute *CAttributeList::GetAttributeByID( int iAttributeID ) const
{
int iAttributes = m_Attributes.Count();
for ( int i = 0; i < iAttributes; i++ )
{
const CEconItemAttributeDefinition *pData = m_Attributes[i].GetStaticData();
if ( pData && ( pData->GetDefinitionIndex() == iAttributeID ) )
return &m_Attributes[i];
}
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const CEconItemAttribute *CAttributeList::GetAttributeByName( const char *pszAttribDefName ) const
{
CEconItemAttributeDefinition *pDef = GetItemSchema()->GetAttributeDefinitionByName( pszAttribDefName );
if ( !pDef )
return NULL;
int iAttributes = m_Attributes.Count();
for ( int i = 0; i < iAttributes; i++ )
{
if ( m_Attributes[i].GetStaticData()->GetDefinitionIndex() == pDef->GetDefinitionIndex() )
return &m_Attributes[i];
}
return NULL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::operator=( const CAttributeList& src )
{
m_Attributes = src.m_Attributes;
// HACK: We deliberately don't copy managers, because attributelists are contained inside
// CEconItemViews, which we duplicate inside CItemModelPanels all the time. If the manager
// is copied, copies will mess with the attribute caches of the copied item.
// Our manager will be setup properly by the CAttributeManager itself if we have an associated entity.
m_pManager = NULL;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAttributeList::NotifyManagerOfAttributeValueChanges( void )
{
if ( m_pManager )
{
m_pManager->OnAttributeValuesChanged();
}
}
#ifdef CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool DoesItemPassSearchFilter( const IEconItemDescription *pDescription, const wchar_t* wszFilter )
{
// check if item matches name filter
if ( wszFilter && *wszFilter )
{
if ( !pDescription )
{
return false;
}
wchar_t wszBuffer[ 4096 ] = L"";
for ( unsigned int i = 0; i < pDescription->GetLineCount(); i++ )
{
const econ_item_description_line_t& line = pDescription->GetLine(i);
if ( !(line.unMetaType & ( kDescLineFlag_Collection | kDescLineFlag_CollectionCurrentItem ) ) )
{
V_wcscat_safe( wszBuffer, line.sText.Get() );
}
}
V_wcslower( wszBuffer );
if ( !wcsstr( wszBuffer, wszFilter ) )
{
return false;
}
}
return true;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CBasePlayer *GetPlayerByAccountID( uint32 unAccountID )
{
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex( i );
if ( pPlayer == NULL )
continue;
CSteamID steamIDPlayer;
if ( !pPlayer->GetSteamID( &steamIDPlayer ) )
continue;
// return the player with the matching ID
if ( steamIDPlayer.GetAccountID() == unAccountID )
{
return pPlayer;
}
}
return NULL;
}
#endif // CLIENT_DLL
|