Skip to content

Commit 352f078

Browse files
JoinedSensesHeadline
authored andcommitted
Add Cookie methodmap (#1012)
1 parent 4f3c317 commit 352f078

3 files changed

Lines changed: 231 additions & 88 deletions

File tree

core/smn_keyvalues.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
11041104
static cell_t KeyValues_Import(IPluginContext *pContext, const cell_t *params)
11051105
{
11061106
// This version takes (dest, src). The original is (src, dest).
1107-
cell_t new_params[3] = {
1107+
const cell_t new_params[3] = {
11081108
2,
11091109
params[2],
11101110
params[1],

extensions/clientprefs/natives.cpp

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -471,20 +471,82 @@ cell_t GetClientCookieTime(IPluginContext *pContext, const cell_t *params)
471471
return value;
472472
}
473473

474+
static cell_t Cookie_Set(IPluginContext *pContext, const cell_t *params)
475+
{
476+
// This version takes (handle, client, value). The original is (client, handle, value).
477+
const cell_t new_params[4] = {
478+
3,
479+
params[2],
480+
params[1],
481+
params[3]
482+
};
483+
484+
return SetClientPrefCookie(pContext, new_params);
485+
}
486+
487+
static cell_t Cookie_Get(IPluginContext *pContext, const cell_t *params)
488+
{
489+
// This verson takes (handle, client, buffer, maxlen). The original is (client, handle, buffer, maxlen).
490+
const cell_t new_params[5] = {
491+
4,
492+
params[2],
493+
params[1],
494+
params[3],
495+
params[4]
496+
};
497+
498+
return GetClientPrefCookie(pContext, new_params);
499+
}
500+
501+
static cell_t Cookie_SetByAuthId(IPluginContext *pContext, const cell_t *params)
502+
{
503+
// This version takes (handle, authid, value). The original is (authid, handle, value).
504+
const cell_t new_params[4] = {
505+
3,
506+
params[2],
507+
params[1],
508+
params[3]
509+
};
510+
511+
return SetAuthIdCookie(pContext, new_params);
512+
}
513+
514+
static cell_t Cookie_GetClientTime(IPluginContext *pContext, const cell_t *params)
515+
{
516+
// This version takes (handle, client). The original is (client, handle)
517+
const cell_t new_params[3] = {
518+
2,
519+
params[2],
520+
params[1],
521+
};
522+
523+
return GetClientCookieTime(pContext, new_params);
524+
}
525+
474526
sp_nativeinfo_t g_ClientPrefNatives[] =
475527
{
476-
{"RegClientCookie", RegClientPrefCookie},
477-
{"FindClientCookie", FindClientPrefCookie},
478-
{"SetClientCookie", SetClientPrefCookie},
479-
{"SetAuthIdCookie", SetAuthIdCookie},
480-
{"GetClientCookie", GetClientPrefCookie},
481-
{"AreClientCookiesCached", AreClientCookiesCached},
482-
{"GetCookieAccess", GetCookieAccess},
483-
{"ReadCookieIterator", ReadCookieIterator},
484-
{"GetCookieIterator", GetCookieIterator},
485-
{"ShowCookieMenu", ShowSettingsMenu},
486-
{"SetCookieMenuItem", AddSettingsMenuItem},
487-
{"SetCookiePrefabMenu", AddSettingsPrefabMenuItem},
528+
{"RegClientCookie", RegClientPrefCookie},
529+
{"FindClientCookie", FindClientPrefCookie},
530+
{"SetClientCookie", SetClientPrefCookie},
531+
{"SetAuthIdCookie", SetAuthIdCookie},
532+
{"GetClientCookie", GetClientPrefCookie},
533+
{"AreClientCookiesCached", AreClientCookiesCached},
534+
{"GetCookieAccess", GetCookieAccess},
535+
{"ReadCookieIterator", ReadCookieIterator},
536+
{"GetCookieIterator", GetCookieIterator},
537+
{"ShowCookieMenu", ShowSettingsMenu},
538+
{"SetCookieMenuItem", AddSettingsMenuItem},
539+
{"SetCookiePrefabMenu", AddSettingsPrefabMenuItem},
488540
{"GetClientCookieTime", GetClientCookieTime},
489-
{NULL, NULL}
541+
542+
{"Cookie.Cookie", RegClientPrefCookie},
543+
{"Cookie.Find", FindClientPrefCookie},
544+
{"Cookie.Set", Cookie_Set},
545+
{"Cookie.Get", Cookie_Get},
546+
{"Cookie.SetByAuthId", Cookie_SetByAuthId},
547+
{"Cookie.SetPrefabMenu", AddSettingsPrefabMenuItem},
548+
{"Cookie.GetClientTime", Cookie_GetClientTime},
549+
{"Cookie.AccessLevel.get", GetCookieAccess},
550+
551+
{NULL, NULL}
490552
};

0 commit comments

Comments
 (0)