ISource2ModFeatures
Asking whether something optional is there before using it.
SourceMod's GetFeatureStatus, for both kinds of plugin: a native C++ plugin asks before it calls into another plugin's interface or relies on a part of the core that may be switched off (GeoIP without a database), a SourcePawn plugin asks the same through GetFeatureStatus() / Source2ModFeatures.
What can be asked about:
- a native -- a SourcePawn native, the core's own or one a plugin registered (CreateNative, ISource2ModNatives). A plugin native is Unavailable while its plugin is unloaded.
- a capability -- a named part of the core that can be missing at runtime; the names are the SOURCE2MOD_CAPABILITY_* below.
- an interface -- an interface Source2ModFactory() would hand out: the core's (at the exact revision asked for) or one a plugin serves through OnSource2ModQuery.
- a library -- a name a plugin registered (RegPluginLibrary, ISource2ModNatives::RegisterLibrary).
Interface id ISource2ModFeatures001 (SOURCE2MOD_FEATURES_INTERFACE) · Global g_pSource2ModFeatures · Header source2mod/ISource2ModFeatures.h
Methods
GetFeatureStatus
virtual Source2ModFeatureStatus GetFeatureStatus(Source2ModFeatureType type, const char* name) = 0;The status of a native, capability, interface or library.
| Parameter | Type | Description |
|---|---|---|
type | Source2ModFeatureType | What name names. |
name | const char* | The native, capability, interface ("ISource2ModMenus005") or library name. |
IsNativeAvailable
virtual bool IsNativeAvailable(const char* name) = 0;GetFeatureStatus(SOURCE2MOD_FEATURE_NATIVE, name) == AVAILABLE.
| Parameter | Type |
|---|---|
name | const char* |
IsInterfaceAvailable
virtual bool IsInterfaceAvailable(const char* iface) = 0;Whether Source2ModFactory() would hand this interface out right now. Unlike asking the factory, a miss is not logged.
| Parameter | Type |
|---|---|
iface | const char* |
IsLibraryAvailable
virtual bool IsLibraryAvailable(const char* name) = 0;Whether some plugin registered this library and is still loaded.
| Parameter | Type |
|---|---|
name | const char* |
HasCapability
virtual bool HasCapability(const char* name) = 0;Whether a SOURCE2MOD_CAPABILITY_* is usable.
| Parameter | Type |
|---|---|
name | const char* |
Enums
Source2ModFeatureType
enum Source2ModFeatureTypeThe same numbers as SourceMod's FeatureType, plus the two Source2Mod adds.
| Name | Value |
|---|---|
SOURCE2MOD_FEATURE_NATIVE | 0 |
SOURCE2MOD_FEATURE_CAPABILITY | 1 |
SOURCE2MOD_FEATURE_INTERFACE | 2 |
SOURCE2MOD_FEATURE_LIBRARY | 3 |
Source2ModFeatureStatus
enum Source2ModFeatureStatusThe same numbers as SourceMod's FeatureStatus.
| Name | Value | Description |
|---|---|---|
SOURCE2MOD_FEATURE_AVAILABLE | 0 | There, and usable. |
SOURCE2MOD_FEATURE_UNAVAILABLE | 1 | Known, but not usable right now (its plugin unloaded, no database, ...). |
SOURCE2MOD_FEATURE_UNKNOWN | 2 | Not known at all. |
Macros
SOURCE2MOD_CAPABILITY_SOURCEPAWN
#define SOURCE2MOD_CAPABILITY_SOURCEPAWN "sourcepawn"The SourcePawn VM: always there in this core.
SOURCE2MOD_CAPABILITY_GEOIP
#define SOURCE2MOD_CAPABILITY_GEOIP "geoip"GeoIP lookups: a GeoLite2 database was found and opened.
SOURCE2MOD_CAPABILITY_CLIENTPREFS
#define SOURCE2MOD_CAPABILITY_CLIENTPREFS "clientprefs"Client preferences: the cookie database is connected.
SOURCE2MOD_CAPABILITY_GAMESYSTEMS
#define SOURCE2MOD_CAPABILITY_GAMESYSTEMS "gamesystems"Registering game systems (ISource2ModGameSystems::IsAvailable()).