- LibraryExists() now works on extensions
- geoip and cstrike now work as libraries --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401579
This commit is contained in:
parent
c803eb8328
commit
e08b4cdf1e
@ -463,7 +463,17 @@ static cell_t LibraryExists(IPluginContext *pContext, const cell_t *params)
|
|||||||
char *str;
|
char *str;
|
||||||
pContext->LocalToString(params[1], &str);
|
pContext->LocalToString(params[1], &str);
|
||||||
|
|
||||||
return g_PluginSys.LibraryExists(str) ? 1 : 0;
|
if (g_PluginSys.LibraryExists(str))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_Extensions.LibraryExists(str))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params)
|
static cell_t sm_LogAction(IPluginContext *pContext, const cell_t *params)
|
||||||
|
@ -1118,3 +1118,26 @@ void CExtensionManager::AddLibrary(IExtension *pSource, const char *library)
|
|||||||
pExt->AddLibrary(library);
|
pExt->AddLibrary(library);
|
||||||
g_PluginSys.OnLibraryAction(library, false, false);
|
g_PluginSys.OnLibraryAction(library, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CExtensionManager::LibraryExists(const char *library)
|
||||||
|
{
|
||||||
|
CExtension *pExt;
|
||||||
|
|
||||||
|
for (List<CExtension *>::iterator iter = m_Libs.begin();
|
||||||
|
iter != m_Libs.end();
|
||||||
|
iter++)
|
||||||
|
{
|
||||||
|
pExt = (*iter);
|
||||||
|
for (List<String>::iterator s_iter = pExt->m_Libraries.begin();
|
||||||
|
s_iter != pExt->m_Libraries.end();
|
||||||
|
s_iter++)
|
||||||
|
{
|
||||||
|
if ((*s_iter).compare(library) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -135,6 +135,7 @@ public:
|
|||||||
void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
|
void AddDependency(IExtension *pSource, const char *file, bool required, bool autoload);
|
||||||
void TryAutoload();
|
void TryAutoload();
|
||||||
void AddLibrary(IExtension *pSource, const char *library);
|
void AddLibrary(IExtension *pSource, const char *library);
|
||||||
|
bool LibraryExists(const char *library);
|
||||||
public:
|
public:
|
||||||
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
CExtension *GetExtensionFromIdent(IdentityToken_t *ptr);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
|
@ -65,6 +65,7 @@ bool CStrike::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sharesys->AddNatives(myself, g_CSNatives);
|
sharesys->AddNatives(myself, g_CSNatives);
|
||||||
|
sharesys->RegisterLibrary(myself, "cstrike");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ bool GeoIP_Extension::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_pShareSys->AddNatives(myself, geoip_natives);
|
g_pShareSys->AddNatives(myself, geoip_natives);
|
||||||
|
g_pShareSys->RegisterLibrary(myself, "GeoIP");
|
||||||
g_pSM->LogMessage(myself, "GeoIP database info: %s", GeoIP_database_info(gi));
|
g_pSM->LogMessage(myself, "GeoIP database info: %s", GeoIP_database_info(gi));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,7 +71,7 @@ native CS_SwitchTeam(client, team);
|
|||||||
*/
|
*/
|
||||||
public Extension:__ext_cstrike =
|
public Extension:__ext_cstrike =
|
||||||
{
|
{
|
||||||
name = "CStrike",
|
name = "cstrike",
|
||||||
file = "games/game.cstrike.ext",
|
file = "games/game.cstrike.ext",
|
||||||
autoload = 0,
|
autoload = 0,
|
||||||
#if defined REQUIRE_EXTENSIONS
|
#if defined REQUIRE_EXTENSIONS
|
||||||
@ -80,3 +80,11 @@ public Extension:__ext_cstrike =
|
|||||||
required = 0,
|
required = 0,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined REQUIRE_EXTENSIONS
|
||||||
|
public __ext_cstrike_SetNTVOptional()
|
||||||
|
{
|
||||||
|
MarkNativeAsOptional("CS_RespawnPlayer");
|
||||||
|
MarkNativeAsOptional("CS_SwitchTeam");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -91,3 +91,12 @@ public Extension:__ext_geoip =
|
|||||||
required = 0,
|
required = 0,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !defined REQUIRE_EXTENSIONS
|
||||||
|
public __ext_geoip_SetNTVOptional()
|
||||||
|
{
|
||||||
|
MarkNativeAsOptional("GeoipCode2");
|
||||||
|
MarkNativeAsOptional("GeoipCode3");
|
||||||
|
MarkNativeAsOptional("GeoipCountry");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -446,9 +446,12 @@ native MarkNativeAsOptional(const String:name[]);
|
|||||||
native RegPluginLibrary(const String:name[]);
|
native RegPluginLibrary(const String:name[]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a library exists.
|
* Returns whether a library exists. This function should be considered
|
||||||
|
* expensive; it should only be called on plugin to determine availability
|
||||||
|
* of resources. Use OnLibraryAdded()/OnLibraryRemoved() to detect changes
|
||||||
|
* in optional resources.
|
||||||
*
|
*
|
||||||
* @param name Library name.
|
* @param name Library name of a plugin or extension.
|
||||||
* @return True if exists, false otherwise.
|
* @return True if exists, false otherwise.
|
||||||
*/
|
*/
|
||||||
native bool:LibraryExists(const String:name[]);
|
native bool:LibraryExists(const String:name[]);
|
||||||
|
Loading…
Reference in New Issue
Block a user