Raised This Month: $51 Target: $400
 12% 

Server crashing since a few days


Post New Thread Reply   
 
Thread Tools Display Modes
dordnung
Veteran Member
Join Date: Apr 2010
Old 02-04-2014 , 18:23   Re: Server crashing since a few days
Reply With Quote #11

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?
__________________
dordnung is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-05-2014 , 01:12   Re: Server crashing since a few days
Reply With Quote #12

Quote:
Originally Posted by Popoklopsi View Post
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.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-05-2014 at 01:14.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode