1.1 --- a/core/smn_console.cpp Tue Mar 03 09:41:55 2009 -0500
1.2 +++ b/core/smn_console.cpp Thu Mar 05 11:59:49 2009 +1300
1.3 @@ -43,6 +43,7 @@
1.4 #include <inetchannel.h>
1.5 #include <bitbuf.h>
1.6 #include <sm_trie_tpl.h>
1.7 +#include "TagsSystem.h"
1.8
1.9 #if SOURCE_ENGINE == SE_LEFT4DEAD
1.10 #define NET_SETCONVAR 6
1.11 @@ -1304,6 +1305,60 @@
1.12 return 1;
1.13 }
1.14
1.15 +static cell_t AddServerTag(IPluginContext *pContext, const cell_t *params)
1.16 +{
1.17 + char *value;
1.18 + pContext->LocalToString(params[1], &value);
1.19 +
1.20 + if (!g_Tags.AddTag(value))
1.21 + {
1.22 + return 0;
1.23 + }
1.24 +
1.25 + IPlugin *pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
1.26 + SourceHook::List<char *> *pList = NULL;
1.27 +
1.28 + if (!pPlugin->GetProperty("ServerTags", (void **)&pList, false) || !pList)
1.29 + {
1.30 + pList = new SourceHook::List<char *>;
1.31 + pPlugin->SetProperty("ServerTags", pList);
1.32 + }
1.33 +
1.34 + pList->push_back(strdup(value));
1.35 +
1.36 + return 1;
1.37 +}
1.38 +
1.39 +static cell_t RemoveServerTag(IPluginContext *pContext, const cell_t *params)
1.40 +{
1.41 + char *value;
1.42 + pContext->LocalToString(params[1], &value);
1.43 +
1.44 + IPlugin *pPlugin = g_PluginSys.FindPluginByContext(pContext->GetContext());
1.45 + SourceHook::List<char *> *pList = NULL;
1.46 +
1.47 + if (!pPlugin->GetProperty("ServerTags", (void **)&pList, false) || !pList)
1.48 + {
1.49 + pList = new SourceHook::List<char *>;
1.50 + pPlugin->SetProperty("ServerTags", pList);
1.51 + }
1.52 +
1.53 + SourceHook::List<char *>::iterator iter = pList->begin();
1.54 +
1.55 + while (iter != pList->end())
1.56 + {
1.57 + if (strcmp(*iter, value) == 0)
1.58 + {
1.59 + g_pMemAlloc->Free(*iter);
1.60 + pList->erase(iter);
1.61 +
1.62 + return g_Tags.RemoveTag(value);
1.63 + }
1.64 + }
1.65 +
1.66 + return 0;
1.67 +}
1.68 +
1.69 REGISTER_NATIVES(consoleNatives)
1.70 {
1.71 {"CreateConVar", sm_CreateConVar},
1.72 @@ -1351,5 +1406,7 @@
1.73 {"FindFirstConCommand", FindFirstConCommand},
1.74 {"FindNextConCommand", FindNextConCommand},
1.75 {"SendConVarValue", SendConVarValue},
1.76 + {"AddServerTag", AddServerTag},
1.77 + {"RemoveServerTag", RemoveServerTag},
1.78 {NULL, NULL}
1.79 };