1.1 --- a/core/logic/PluginSys.cpp Sun Aug 25 11:59:45 2013 -0700
1.2 +++ b/core/logic/PluginSys.cpp Sun Aug 25 11:59:46 2013 -0700
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * vim: set ts=4 :
1.6 + * vim: set ts=4 sw=4 tw=99 noet :
1.7 * =============================================================================
1.8 * SourceMod
1.9 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.10 @@ -114,7 +114,7 @@
1.11 sizeof(CPlugin)
1.12 + sizeof(IdentityToken_t)
1.13 + (m_configs.size() * (sizeof(AutoConfig *) + sizeof(AutoConfig)))
1.14 - + m_pProps.mem_usage();
1.15 + + m_Props.mem_usage();
1.16
1.17 for (unsigned int i = 0; i < m_configs.size(); i++)
1.18 {
1.19 @@ -169,24 +169,22 @@
1.20
1.21 bool CPlugin::GetProperty(const char *prop, void **ptr, bool remove/* =false */)
1.22 {
1.23 - void **ptrpp = m_pProps.retrieve(prop);
1.24 - bool exists = !!ptrpp;
1.25 + StringHashMap<void *>::Result r = m_Props.find(prop);
1.26 + if (!r.found())
1.27 + return false;
1.28
1.29 - if (exists)
1.30 - {
1.31 - if (ptr)
1.32 - *ptr = *ptrpp;
1.33 -
1.34 - if (remove)
1.35 - m_pProps.remove(prop);
1.36 - }
1.37 + if (ptr)
1.38 + *ptr = r->value;
1.39
1.40 - return exists;
1.41 + if (remove)
1.42 + m_Props.remove(r);
1.43 +
1.44 + return true;
1.45 }
1.46
1.47 bool CPlugin::SetProperty(const char *prop, void *ptr)
1.48 {
1.49 - return m_pProps.insert(prop, ptr);
1.50 + return m_Props.insert(prop, ptr);
1.51 }
1.52
1.53 IPluginRuntime *CPlugin::GetRuntime()
1.54 @@ -886,22 +884,19 @@
1.55 libsys->CloseDirectory(dir);
1.56 }
1.57
1.58 -LoadRes CPluginManager::_LoadPlugin(CPlugin **_plugin, const char *path, bool debug, PluginType type, char error[], size_t maxlength)
1.59 +LoadRes CPluginManager::_LoadPlugin(CPlugin **aResult, const char *path, bool debug, PluginType type, char error[], size_t maxlength)
1.60 {
1.61 if (m_LoadingLocked)
1.62 - {
1.63 return LoadRes_NeverLoad;
1.64 - }
1.65
1.66 int err;
1.67
1.68 /**
1.69 * Does this plugin already exist?
1.70 */
1.71 - CPlugin **pluginpp = m_LoadLookup.retrieve(path);
1.72 - if (pluginpp && *pluginpp)
1.73 + CPlugin *pPlugin;
1.74 + if (m_LoadLookup.retrieve(path, &pPlugin))
1.75 {
1.76 - CPlugin *pPlugin = *pluginpp;
1.77 /* Check to see if we should try reloading it */
1.78 if (pPlugin->GetStatus() == Plugin_BadLoad
1.79 || pPlugin->GetStatus() == Plugin_Error
1.80 @@ -911,16 +906,13 @@
1.81 }
1.82 else
1.83 {
1.84 - if (_plugin)
1.85 - {
1.86 - *_plugin = pPlugin;
1.87 - }
1.88 + if (aResult)
1.89 + *aResult = pPlugin;
1.90 return LoadRes_AlreadyLoaded;
1.91 }
1.92 }
1.93
1.94 - CPlugin *pPlugin = CPlugin::CreatePlugin(path, error, maxlength);
1.95 -
1.96 + pPlugin = CPlugin::CreatePlugin(path, error, maxlength);
1.97 assert(pPlugin != NULL);
1.98
1.99 pPlugin->m_type = PluginType_MapUpdated;
1.100 @@ -1034,10 +1026,8 @@
1.101 time_t t = pPlugin->GetFileTimeStamp();
1.102 pPlugin->SetTimeStamp(t);
1.103
1.104 - if (_plugin)
1.105 - {
1.106 - *_plugin = pPlugin;
1.107 - }
1.108 + if (aResult)
1.109 + *aResult = pPlugin;
1.110
1.111 return (pPlugin->GetStatus() == Plugin_Loaded) ? LoadRes_Successful : loadFailure;
1.112 }
1.113 @@ -2114,13 +2104,11 @@
1.114 const char *ext = libsys->GetFileExtension(arg) ? "" : ".smx";
1.115 g_pSM->BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.116
1.117 - CPlugin **pluginpp = m_LoadLookup.retrieve(pluginfile);
1.118 - if (!pluginpp || !*pluginpp)
1.119 + if (!m_LoadLookup.retrieve(pluginfile, &pl))
1.120 {
1.121 rootmenu->ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
1.122 return;
1.123 }
1.124 - pl = *pluginpp;
1.125 }
1.126
1.127 char name[PLATFORM_MAX_PATH];
1.128 @@ -2206,13 +2194,11 @@
1.129 const char *ext = libsys->GetFileExtension(arg) ? "" : ".smx";
1.130 g_pSM->BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.131
1.132 - CPlugin **pluginpp = m_LoadLookup.retrieve(pluginfile);
1.133 - if (!pluginpp || !*pluginpp)
1.134 + if (!m_LoadLookup.retrieve(pluginfile, &pl))
1.135 {
1.136 rootmenu->ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
1.137 return;
1.138 }
1.139 - pl = *pluginpp;
1.140 }
1.141
1.142 const sm_plugininfo_t *info = pl->GetPublicInfo();
1.143 @@ -2338,13 +2324,11 @@
1.144 const char *ext = libsys->GetFileExtension(arg) ? "" : ".smx";
1.145 g_pSM->BuildPath(Path_None, pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.146
1.147 - CPlugin **pluginpp = m_LoadLookup.retrieve(pluginfile);
1.148 - if (!pluginpp || !*pluginpp)
1.149 + if (!m_LoadLookup.retrieve(pluginfile, &pl))
1.150 {
1.151 rootmenu->ConsolePrint("[SM] Plugin %s is not loaded.", pluginfile);
1.152 return;
1.153 }
1.154 - pl = *pluginpp;
1.155 }
1.156
1.157 char name[PLATFORM_MAX_PATH];
1.158 @@ -2604,13 +2588,8 @@
1.159 const char *ext = libsys->GetFileExtension(arg) ? "" : ".smx";
1.160 smcore.Format(pluginfile, sizeof(pluginfile), "%s%s", arg, ext);
1.161
1.162 - CPlugin **pluginpp = m_LoadLookup.retrieve(pluginfile);
1.163 - if (!pluginpp)
1.164 - {
1.165 + if (!m_LoadLookup.retrieve(pluginfile, &pl))
1.166 return NULL;
1.167 - }
1.168 -
1.169 - pl = *pluginpp;
1.170 }
1.171
1.172 return pl;