1.1 --- a/core/PlayerManager.cpp Fri Mar 29 12:28:02 2013 -0400
1.2 +++ b/core/PlayerManager.cpp Fri Mar 29 11:37:29 2013 -0700
1.3 @@ -31,7 +31,6 @@
1.4
1.5 #include "PlayerManager.h"
1.6 #include "ForwardSys.h"
1.7 -#include "ShareSys.h"
1.8 #include "AdminCache.h"
1.9 #include "ConCmdManager.h"
1.10 #include "MenuStyle_Valve.h"
1.11 @@ -45,7 +44,6 @@
1.12 #include <inetchannel.h>
1.13 #include <iclient.h>
1.14 #include <IGameConfigs.h>
1.15 -#include "ExtensionSys.h"
1.16 #include <sourcemod_version.h>
1.17 #include "ConsoleDetours.h"
1.18 #include "logic_bridge.h"
1.19 @@ -141,7 +139,7 @@
1.20 SH_ADD_HOOK(IServerGameClients, ClientSettingsChanged, serverClients, SH_MEMBER(this, &PlayerManager::OnClientSettingsChanged), true);
1.21 SH_ADD_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true);
1.22
1.23 - g_ShareSys.AddInterface(NULL, this);
1.24 + sharesys->AddInterface(NULL, this);
1.25
1.26 ParamType p1[] = {Param_Cell, Param_String, Param_Cell};
1.27 ParamType p2[] = {Param_Cell};
1.28 @@ -278,11 +276,11 @@
1.29 g_NumPlayersToAuth = &m_AuthQueue[0];
1.30 }
1.31
1.32 - g_PluginSys.SyncMaxClients(m_maxClients);
1.33 + scripts->SyncMaxClients(m_maxClients);
1.34
1.35 g_OnMapStarted = true;
1.36
1.37 - g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, m_maxClients);
1.38 + extsys->CallOnCoreMapStart(pEdictList, edictCount, m_maxClients);
1.39 m_onActivate->Execute(NULL);
1.40 m_onActivate2->Execute(NULL);
1.41
1.42 @@ -779,6 +777,173 @@
1.43 engine->ClientPrintf(e, buffer);
1.44 }
1.45
1.46 +void ListExtensionsToClient(CPlayer *player, const CCommand &args)
1.47 +{
1.48 + char buffer[256];
1.49 + unsigned int id = 0;
1.50 + unsigned int start = 0;
1.51 +
1.52 + CVector<IExtension *> extensions;
1.53 + extsys->ListExtensions(&extensions);
1.54 +
1.55 + if (!extensions.size())
1.56 + {
1.57 + ClientConsolePrint(player->GetEdict(), "[SM] No extensions found.");
1.58 + return;
1.59 + }
1.60 +
1.61 + if (args.ArgC() > 2)
1.62 + {
1.63 + start = atoi(args.Arg(2));
1.64 + }
1.65 +
1.66 + SourceHook::CVector<IExtension *>::iterator iter;
1.67 +
1.68 + for (iter = extensions.begin();
1.69 + iter != extensions.end();
1.70 + iter++)
1.71 + {
1.72 + IExtension *ext = (*iter);
1.73 +
1.74 + char error[255];
1.75 + if (!ext->IsRunning(error, sizeof(error)))
1.76 + {
1.77 + continue;
1.78 + }
1.79 +
1.80 + id++;
1.81 + if (id < start)
1.82 + {
1.83 + continue;
1.84 + }
1.85 +
1.86 + if (id - start > 10)
1.87 + {
1.88 + break;
1.89 + }
1.90 +
1.91 + IExtensionInterface *api = ext->GetAPI();
1.92 +
1.93 + const char *name = api->GetExtensionName();
1.94 + const char *version = api->GetExtensionVerString();
1.95 + const char *author = api->GetExtensionAuthor();
1.96 + const char *description = api->GetExtensionDescription();
1.97 +
1.98 + size_t len = UTIL_Format(buffer, sizeof(buffer), " \"%s\"", name);
1.99 +
1.100 + if (version != NULL && version[0])
1.101 + {
1.102 + len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", version);
1.103 + }
1.104 +
1.105 + if (author != NULL && author[0])
1.106 + {
1.107 + len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", author);
1.108 + }
1.109 +
1.110 + if (description != NULL && description[0])
1.111 + {
1.112 + len += UTIL_Format(&buffer[len], sizeof(buffer)-len, ": %s", description);
1.113 + }
1.114 +
1.115 +
1.116 + ClientConsolePrint(player->GetEdict(), "%s", buffer);
1.117 + }
1.118 +
1.119 + for (; iter != extensions.end(); iter++)
1.120 + {
1.121 + char error[255];
1.122 + if ((*iter)->IsRunning(error, sizeof(error)))
1.123 + {
1.124 + break;
1.125 + }
1.126 + }
1.127 +
1.128 + if (iter != extensions.end())
1.129 + {
1.130 + ClientConsolePrint(player->GetEdict(), "To see more, type \"sm exts %d\"", id);
1.131 + }
1.132 +}
1.133 +
1.134 +void ListPluginsToClient(CPlayer *player, const CCommand &args)
1.135 +{
1.136 + char buffer[256];
1.137 + unsigned int id = 0;
1.138 + edict_t *e = player->GetEdict();
1.139 + unsigned int start = 0;
1.140 +
1.141 + CVector<SMPlugin *> plugins;
1.142 + scripts->ListPlugins(&plugins);
1.143 +
1.144 + if (!plugins.size())
1.145 + {
1.146 + ClientConsolePrint(e, "[SM] No plugins found.");
1.147 + return;
1.148 + }
1.149 +
1.150 + if (args.ArgC() > 2)
1.151 + {
1.152 + start = atoi(args.Arg(2));
1.153 + }
1.154 +
1.155 + SourceHook::List<SMPlugin *> m_FailList;
1.156 +
1.157 + CVector<SMPlugin *>::iterator iter = plugins.begin();
1.158 + for (; iter != plugins.end(); iter++)
1.159 + {
1.160 + SMPlugin *pl = *iter;
1.161 +
1.162 + if (pl->GetStatus() != Plugin_Running)
1.163 + {
1.164 + continue;
1.165 + }
1.166 +
1.167 + /* Count valid plugins */
1.168 + id++;
1.169 + if (id < start)
1.170 + {
1.171 + continue;
1.172 + }
1.173 +
1.174 + if (id - start > 10)
1.175 + {
1.176 + break;
1.177 + }
1.178 +
1.179 + size_t len;
1.180 + const sm_plugininfo_t *info = pl->GetPublicInfo();
1.181 + len = UTIL_Format(buffer, sizeof(buffer), " \"%s\"", (IS_STR_FILLED(info->name)) ? info->name : pl->GetFilename());
1.182 + if (IS_STR_FILLED(info->version))
1.183 + {
1.184 + len += UTIL_Format(&buffer[len], sizeof(buffer)-len, " (%s)", info->version);
1.185 + }
1.186 + if (IS_STR_FILLED(info->author))
1.187 + {
1.188 + UTIL_Format(&buffer[len], sizeof(buffer)-len, " by %s", info->author);
1.189 + }
1.190 + else
1.191 + {
1.192 + UTIL_Format(&buffer[len], sizeof(buffer)-len, " %s", pl->GetFilename());
1.193 + }
1.194 + ClientConsolePrint(e, "%s", buffer);
1.195 + }
1.196 +
1.197 + /* See if we can get more plugins */
1.198 + for (; iter != plugins.end(); iter++)
1.199 + {
1.200 + if ((*iter)->GetStatus() == Plugin_Running)
1.201 + {
1.202 + break;
1.203 + }
1.204 + }
1.205 +
1.206 + /* Do we actually have more plugins? */
1.207 + if (iter != plugins.end())
1.208 + {
1.209 + ClientConsolePrint(e, "To see more, type \"sm plugins %d\"", id);
1.210 + }
1.211 +}
1.212 +
1.213 #if SOURCE_ENGINE >= SE_ORANGEBOX
1.214 void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
1.215 {
1.216 @@ -800,12 +965,12 @@
1.217 {
1.218 if (args.ArgC() > 1 && strcmp(args.Arg(1), "plugins") == 0)
1.219 {
1.220 - g_PluginSys.ListPluginsToClient(pPlayer, args);
1.221 + ListPluginsToClient(pPlayer, args);
1.222 RETURN_META(MRES_SUPERCEDE);
1.223 }
1.224 else if (args.ArgC() > 1 && strcmp(args.Arg(1), "exts") == 0)
1.225 {
1.226 - g_Extensions.ListExtensionsToClient(pPlayer, args);
1.227 + ListExtensionsToClient(pPlayer, args);
1.228 RETURN_META(MRES_SUPERCEDE);
1.229 }
1.230 else if (args.ArgC() > 1 && strcmp(args.Arg(1), "credits") == 0)
1.231 @@ -1641,9 +1806,9 @@
1.232 m_AuthID.assign(steamid);
1.233 }
1.234
1.235 -// Ensure a valid AuthString is set before calling.
1.236 -void CPlayer::Authorize()
1.237 -{
1.238 +// Ensure a valid AuthString is set before calling.
1.239 +void CPlayer::Authorize()
1.240 +{
1.241 m_IsAuthorized = true;
1.242 }
1.243
1.244 @@ -1690,9 +1855,9 @@
1.245
1.246 const char *CPlayer::GetAuthString(bool validated)
1.247 {
1.248 - if (validated && !IsAuthStringValidated())
1.249 - {
1.250 - return NULL;
1.251 + if (validated && !IsAuthStringValidated())
1.252 + {
1.253 + return NULL;
1.254 }
1.255
1.256 return m_AuthID.c_str();
1.257 @@ -1752,15 +1917,15 @@
1.258 return m_IsAuthorized;
1.259 }
1.260
1.261 -bool CPlayer::IsAuthStringValidated()
1.262 +bool CPlayer::IsAuthStringValidated()
1.263 {
1.264 #if SOURCE_ENGINE >= SE_ORANGEBOX
1.265 - if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
1.266 - {
1.267 - return engine->IsClientFullyAuthenticated(m_pEdict);
1.268 - }
1.269 -#endif
1.270 -
1.271 + if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
1.272 + {
1.273 + return engine->IsClientFullyAuthenticated(m_pEdict);
1.274 + }
1.275 +#endif
1.276 +
1.277 return true;
1.278 }
1.279