CounterStrikeSharp icon indicating copy to clipboard operation
CounterStrikeSharp copied to clipboard

Implement CVariant functions

Open zonical opened this issue 1 year ago • 11 comments

~~Very work in progress - working on it in small bits at a time~~

This PR aims to implement functions to CVariant which accesses data from variant_t on the C++ side. Useful for functions that hook into the Entity IO system. ~~Unsure if a Set function is needed - but it can probably be done.~~

zonical avatar Sep 01 '24 02:09 zonical

I've also added a function to get a string from a CUtlSymbolLarge class for plugin authors that wish to hook into AcceptInput without dealing with memory shenanigans on the C# side. Does not appear to have an easy way to modify it (from my little knowledge of hl2sdk) so it will remain as read-only.

zonical avatar Sep 01 '24 21:09 zonical

you can just use fieldtype_t to replace VariantFieldTypes, fieldtype_t is generated from the schema

Yarukon avatar Sep 16 '24 05:09 Yarukon

LGTM!

Does not appear to have an easy way to modify it (from my little knowledge of hl2sdk) so it will remain as read-only.

Maybe modify it through a native call?

KillStr3aK avatar Oct 07 '24 21:10 KillStr3aK

Finally had the time to work on this again. Added a Set() function with corresponding native functions. Currently untested (and I can't test at the moment - so I would be grateful if someone could!)

@Yarukon - I've also used the generated field as you suggested. Thanks for the suggestion!

zonical avatar Oct 08 '24 05:10 zonical

I've left probably my last reviews on this, good job!

KillStr3aK avatar Oct 08 '24 08:10 KillStr3aK

@KillStr3aK Your cleanup suggestions have been made!

zonical avatar Oct 09 '24 08:10 zonical

will this be added to the main branch?

darkerz7 avatar Jan 10 '25 03:01 darkerz7

will this be added to the main branch?

I hope so. I've been using a local version of CounterStrikeSharp with this feature for a while, and I've not encountered any massive issues. cc: @roflmuffin for review?

zonical avatar Jan 11 '25 23:01 zonical

will this be added to the main branch?

I hope so. I've been using a local version of CounterStrikeSharp with this feature for a while, and I've not encountered any massive issues. cc: @roflmuffin for review?

I did actually run into a crash or two, so I might investigate this code a bit further.

zonical avatar Jan 12 '25 10:01 zonical

Hey @zonical, the changes look good to me, do you anticipate that your latest commit adds more safety to prevent the crashes? Do you need some more time to test

roflmuffin avatar Jan 12 '25 23:01 roflmuffin

Hey @zonical, the changes look good to me, do you anticipate that your latest commit adds more safety to prevent the crashes? Do you need some more time to test

I will need more time. Some of the crashes I've been having on my testing server seem to be resolved after my latest commit, but I want to ensure that everything is fully safe before merging.

zonical avatar Jan 13 '25 09:01 zonical

Tried doing a massive rebase with latest code (this branch went extremely stale) and it fucked everything. New PR with a clean slate coming shortly!

zonical avatar Jun 27 '25 21:06 zonical