-
Notifications
You must be signed in to change notification settings - Fork 1
Add support for reading / writing string attributes #4
Conversation
std::string is implemented differently on each platform, so we'll just let the game's own function handle it accordingly.
a5fbfec
to
ee7b891
Compare
This one was a doozy. The latest commit adds It somehow Just Works™ on strings applied as runtime attributes (even though they can't be synchronized across the client/server divide). Some preliminary micro benchmarks indicate that
In case you need to migrate between development versions, here's what you need to change: #define ATTRIBUTE_NAME "custom name attr"
#define ATTRIBUTE_CLASS "custom_name_attr"
TF2Attrib_GetStringValue(entity, ATTRIBUTE_NAME, buffer, sizeof(buffer));
TF2Attrib_HookValueString("", ATTRIBUTE_CLASS, entity, buffer, sizeof(buffer)); |
Apparently OnPluginEnd() doesn't call OnMapEnd(), so we'll have to duplicate our efforts here.
The entities can't keep them, since the plugin is the only one able to manage attributes.
🦀 |
メリークリスマス
This PR introduces string attributes through the following changes:
TF2Attrib_SetFromStringValue
, which takes an attribute name and value string and performs any appropriate internal conversions (uses the same logic that the game uses for schema key / value parsing into values) and applies it as a runtime attribute.New nativeTF2Attrib_GetStringValue
, which takes a string attribute name and returns the first valid string value it finds for that attribute on an entity (prioritizing attributes applied on runtime, GC, then static).See comment further down in this PR; this native has a successor.TF2Attrib_UnsafeGetStringValue
to read arbitrary attribute string values instead of following the priority rules above.be deduplicating strings andcleaner unload logic).The potential use cases for this include:
override projectile model
).This bumps up the minimum required SourceMod compiler version to 1.10. I could backport the one enum struct that is used, but I think we should be fine not targeting anything older than the current stable release.
This supercedes and closes FlaminSarge#41.
Mainly self-PRing this to CC @FlaminSarge for review, gotta make sure the API design looks fine