Skip to content
Permalink
Browse files

Add Cookie methodmap (#1012)

  • Loading branch information...
JoinedSenses authored and Headline committed May 31, 2019
1 parent 4f3c317 commit 352f078b07667271dee6d5bab0c99f34cd2b273e
Showing with 231 additions and 88 deletions.
  1. +1 −1 core/smn_keyvalues.cpp
  2. +75 −13 extensions/clientprefs/natives.cpp
  3. +155 −74 plugins/include/clientprefs.inc
@@ -1104,7 +1104,7 @@ static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
static cell_t KeyValues_Import(IPluginContext *pContext, const cell_t *params)
{
// This version takes (dest, src). The original is (src, dest).
cell_t new_params[3] = {
const cell_t new_params[3] = {
2,
params[2],
params[1],
@@ -471,20 +471,82 @@ cell_t GetClientCookieTime(IPluginContext *pContext, const cell_t *params)
return value;
}

static cell_t Cookie_Set(IPluginContext *pContext, const cell_t *params)
{
// This version takes (handle, client, value). The original is (client, handle, value).
const cell_t new_params[4] = {
3,
params[2],
params[1],
params[3]
};

return SetClientPrefCookie(pContext, new_params);
}

static cell_t Cookie_Get(IPluginContext *pContext, const cell_t *params)
{
// This verson takes (handle, client, buffer, maxlen). The original is (client, handle, buffer, maxlen).
const cell_t new_params[5] = {
4,
params[2],
params[1],
params[3],
params[4]
};

return GetClientPrefCookie(pContext, new_params);
}

static cell_t Cookie_SetByAuthId(IPluginContext *pContext, const cell_t *params)
{
// This version takes (handle, authid, value). The original is (authid, handle, value).
const cell_t new_params[4] = {
3,
params[2],
params[1],
params[3]
};

return SetAuthIdCookie(pContext, new_params);
}

static cell_t Cookie_GetClientTime(IPluginContext *pContext, const cell_t *params)
{
// This version takes (handle, client). The original is (client, handle)
const cell_t new_params[3] = {
2,
params[2],
params[1],
};

return GetClientCookieTime(pContext, new_params);
}

sp_nativeinfo_t g_ClientPrefNatives[] =
{
{"RegClientCookie", RegClientPrefCookie},
{"FindClientCookie", FindClientPrefCookie},
{"SetClientCookie", SetClientPrefCookie},
{"SetAuthIdCookie", SetAuthIdCookie},
{"GetClientCookie", GetClientPrefCookie},
{"AreClientCookiesCached", AreClientCookiesCached},
{"GetCookieAccess", GetCookieAccess},
{"ReadCookieIterator", ReadCookieIterator},
{"GetCookieIterator", GetCookieIterator},
{"ShowCookieMenu", ShowSettingsMenu},
{"SetCookieMenuItem", AddSettingsMenuItem},
{"SetCookiePrefabMenu", AddSettingsPrefabMenuItem},
{"RegClientCookie", RegClientPrefCookie},
{"FindClientCookie", FindClientPrefCookie},
{"SetClientCookie", SetClientPrefCookie},
{"SetAuthIdCookie", SetAuthIdCookie},
{"GetClientCookie", GetClientPrefCookie},
{"AreClientCookiesCached", AreClientCookiesCached},
{"GetCookieAccess", GetCookieAccess},
{"ReadCookieIterator", ReadCookieIterator},
{"GetCookieIterator", GetCookieIterator},
{"ShowCookieMenu", ShowSettingsMenu},
{"SetCookieMenuItem", AddSettingsMenuItem},
{"SetCookiePrefabMenu", AddSettingsPrefabMenuItem},
{"GetClientCookieTime", GetClientCookieTime},
{NULL, NULL}

{"Cookie.Cookie", RegClientPrefCookie},
{"Cookie.Find", FindClientPrefCookie},
{"Cookie.Set", Cookie_Set},
{"Cookie.Get", Cookie_Get},
{"Cookie.SetByAuthId", Cookie_SetByAuthId},
{"Cookie.SetPrefabMenu", AddSettingsPrefabMenuItem},
{"Cookie.GetClientTime", Cookie_GetClientTime},
{"Cookie.AccessLevel.get", GetCookieAccess},

{NULL, NULL}
};

0 comments on commit 352f078

Please sign in to comment.
You can’t perform that action at this time.