This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
String attributes preview
Pre-release
Pre-release
This prerelease adds support for string attributes! This one was a doozy.
Nobody mentioned any crashes on it, so consider this a stable release.
Added
- Native
TF2Attrib_SetFromStringValue
lets you provide an attribute name and value as a string, then the game just Does The Right Thing™ and parses it into a runtime attribute with the proper type. This uses the same functionality that the game uses when reading attribute key / value pairs from the schema, so it should work with most attributes you throw at it.- Of course, you still can't network custom strings to the client (and they are likely to crash if you use an attribute they attempt to read), so this is only useful for attributes accessed on the server (but! you can inject custom attribute classes into the server's in-memory schema now, so you can use strings for those, too).
- Native
TF2Attrib_HookValueString
, which behaves similar to the otherTF2Attrib_HookValue*
natives — it takes advantage of the game's caching system and takes an attribute class instead of a specific attribute name. You can get the value of an attribute string this way. - Native
TF2Attrib_UnsafeGetStringValue
, which takes a raw attribute value for a string attribute (specifically, an address to aCAttribute_String
instance) and reads out the containing string. - An internal heap-tracking system that manages heap-allocated runtime attributes. The game doesn't manage such things itself (it only does this for GC and static attributes).
- A caching layer for the name / attribute mapping. The precedent was set with the heap-tracking functionality. I was going to commit this separately, but I already pushed more code on top and it's a pain to rebase.