Quote:
Originally Posted by Popoklopsi
But when you set an attribute you don't have to set the number of attributes before, because the array of the attributes has anyway a size of 16.
The number is only needed after OnGiveNamedItem, so you could also check how many attributes are set, and set m_iCount to it.
So why we need to set the number of attributes explicitly?
|
RAII. My understanding is that creating an array of 16 CEconItemAttribute creates 16 objects automagically... so no, you can't tell how many are actually set just by checking how many exist. (Incidentally, this wouldn't happen if it was an array of CEconItemAttribute*)
In theory, you could tell how many are set by tracking the highest index of the TF2Items_SetAttribute calls on a handle... but if TF2Items ever gains the ability to read existing attributes this will... do unexpected things.
__________________