Added cookie methodmap (clientprefs)#1012
Added cookie methodmap (clientprefs)#1012Headline merged 13 commits intoalliedmodders:masterfrom JoinedSenses:patch-clientprefs
Conversation
|
If there is a better solution for handling the methods where the Handle is not the first param, please let me know. |
I think for other similar cases, we did the same shim but on the C++ side to give us more flexibility for future. |
|
Happen to have any examples? I spent an hour or two digging for similar cases, but couldnt find anything, although good chance I overlooked it. By doing it on C++ side, how would it be handled? Creating a new native callback specifically for the methodmap? |
|
Yeah, you'd create a native that just either calls the other native (similar to what you did), or one that calls the same internal function that the other native wraps (with the difference in parameters). f020b56 is an example |
|
Merge conflict existing due to moving typedef to top of inc, allowing it to be defined for the methodmap. |
This PR adds a methodmap for clientprefs cookies without breaking changes, considering that the cookie Handle is not always the first param for clientprefs functions.
I implemented the switching to the c++ side of things and made the methodmap functions natives.
Headline
left a comment
There was a problem hiding this comment.
Just one little comment, I'll be happy to merge after that change
Nice work! 🎉
extensions/clientprefs/natives.cpp
Outdated
| static cell_t Cookie_Set(IPluginContext *pContext, const cell_t *params) | ||
| { | ||
| // This version takes (handle, client, value). The original is (client, handle, value). | ||
| cell_t new_params[4] = { |
There was a problem hiding this comment.
can you mark this const?
this along with the others
There was a problem hiding this comment.
Should this then be made const as well, the commit change I used for reference? https://github.com/alliedmodders/sourcemod/blob/master/core/smn_keyvalues.cpp#L1107
|
Tested with: Results: |
This PR adds a methodmap for clientprefs cookies without breaking changes, considering that the cookie Handle is not always the first param for clientprefs functions.