-
-
Notifications
You must be signed in to change notification settings - Fork 432
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
Add templated helper class to promote type-safety #965
Conversation
extensions/sdktools/inputnatives.cpp
Outdated
|
||
bool ret; | ||
g_pAcceptInput->Execute(vstk, &ret); | ||
MemWriter<void*, const char*, CBaseEntity*, CBaseEntity*, decltype(g_Variant_t), int> vstk(pDest, inputname, pActivator, pCaller, g_Variant_t, params[5]); |
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.
in-case anyone's curious, this decltype(g_Variant_t)
should be okay since it's a global char[] (not char*)
char test[32];
std::cout << sizeof(test) << std::endl; //32
std::cout << sizeof(decltype(test)) << std::endl; //32
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 is nice; but there's a multitude of style defects and I'd like to know why we're calling malloc when we can hopefully use stack storage instead.
Things should be a-okay now. Buffer is now statically allocated, renamed it per the suggestion to |
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.
The style is still wildly inconsistent 😢
This is a really nice quality-of-life improvement. Obviously it looks sane and should behave sanely, but has this been tested in-game with any of these calls? |
@asherkin no, but I’ve ensured through type-punning by hand that the buffer format is okay. I can do game testing as well to ensure |
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.
Please test in-game to ensure this doesn't break anything. Beyond that fundamentally it's an improvement; thanks for this.
Everything seems to function just as before. Ran through |
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.
@Headline is this waiting on anything else?
@asherkin nope! |
Along with some type safety checks to ensure everything is kosher, this also technically fixes us relying on UB punning.