-
-
Notifications
You must be signed in to change notification settings - Fork 189
feat: add Convar<T> for real convar creation/deletion/access #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f7cd192
to
8d9ea3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome. Would be great to also have a list of known ConVars that utilize this to reduce mistake of accidentally using the wrong type with a ConVar. This however would be fitting in another PR I suppose.
ScriptContext.GlobalScriptContext.Reset(); | ||
ScriptContext.GlobalScriptContext.Push(convar); | ||
ScriptContext.GlobalScriptContext.Push(flags); | ||
ScriptContext.GlobalScriptContext.SetIdentifier(0xB2BDCCBF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic numbers should not be written by themselves. Maybe make them a constant with a name to clarify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are hash calculated native identifiers
|
Yes I know of that. But implement some of these at least into C# as statically typed to make use of the strength of static typing and static code analysis to reduce mistakes and catch erronous usage at compile time. For example would it be suitable to do something similar to this?
|
This PR adds
Convar<T>
which is a strongly typed variant of ConVar which provides better safety (no raw pointer accesses), as well as the ability to create real-convars that exist within the engine (and can be found usingfind foo
in the console) amongst other things.TODO:
.Create
static be restricted?