FlaminSarge / tf2attributes

TF2Attributes SourceMod plugin
49 stars 43 forks source link

Add support for setting String attributes #41

Closed FlaminSarge closed 2 years ago

FlaminSarge commented 3 years ago

This really isn't useful for the things that you can do with it (most of them can be done with SM already in some other way) so this is just for the sake of completeness and for @nosoop to look at.

nosoop commented 3 years ago

I looked at it

"that windows signature is horrifying"

We had an informal discussion on this over DMs yesterday, but in short this iteration is gnarly; it manually initializes a CAttribute_String and uses the game's string pool for the values (edit: if std::string::assign isn't found), and there isn't any checking done to ensure that an attribute takes a string in the first place. (Granted, that last bit also applies to the existing stuff, but runtime attributes are a lot more common.)

I think we agreed that taking advantage of the schema's attribute parsing logic to initialize / construct our values is the approach we'll be taking. Still have to manage the heap-allocated pointers ourselves, but that's something to worry about later.

No matter the approach, this should also be useful for server ops that are declaring new attributes and injecting them into the schema, allowing them to use string values for their attributes. Hopefully the ability to read strings out of attributes also lands in the same release so I can drop my janky KeyValues-in-attribute storage.

nosoop commented 2 years ago

Superceded with the merge of 69dba726f455f6a15015505256e2690080ad924f.