Expose FindMap/ResolveFuzzyMapName to plugins.

This commit is contained in:
Nicholas Hastings
2015-06-27 13:10:47 -04:00
parent 25a8209ffc
commit f107ff9cd2
5 changed files with 126 additions and 28 deletions
+31
View File
@@ -91,6 +91,26 @@ enum EngineVersion
Engine_BlackMesa, /**< Black Mesa Multiplayer */
};
enum FindMapResult
{
// A direct match for this name was found
FindMap_Found,
// No match for this map name could be found.
FindMap_NotFound,
// A fuzzy match for this mapname was found and pMapName was updated to the full name.
// Ex: cp_dust -> cp_dustbowl
// Supported on many newer games.
FindMap_FuzzyMatch,
// A match for this map name was found, and the map name was updated to the canonical version of the
// name.
// Ex: workshop/1234 -> workshop/cp_qualified_name.ugc1234
// Only supported on "Orangebox" games with workshop support.
FindMap_NonCanonical,
// No currently available match for this map name could be found, but it may be possible to load
// Only supported on "Orangebox" games with workshop support.
FindMap_PossiblyAvailable
};
#define INVALID_ENT_REFERENCE 0xFFFFFFFF
/**
@@ -136,6 +156,17 @@ native GetRandomInt(nmin, nmax);
*/
native bool:IsMapValid(const String:map[]);
/**
* Returns whether a full or partial map name is found or can be resolved
*
* @param map Map path relative to maps/ folder, excluding .bsp extension.
* If result is FindMap_FuzzyMatch or FindMap_NonCanonical,
this will be updated to the full path.
* @param maxlen Maximum length to write to map var.
* @return Result of the find operation. Not all result types are supported on all games.
*/
native FindMapResult FindMap(char[] map, int maxlen);
/**
* Returns whether the server is dedicated.
*
+31
View File
@@ -0,0 +1,31 @@
#include <sourcemod>
public void OnPluginStart()
{
RegServerCmd("test_findmap", test_findmap);
}
public Action test_findmap( int argc )
{
char mapName[PLATFORM_MAX_PATH];
GetCmdArg(1, mapName, sizeof(mapName));
char resultName[16];
switch (FindMap(mapName, sizeof(mapName)))
{
case FindMap_Found:
strcopy(resultName, sizeof(resultName), "Found");
case FindMap_NotFound:
strcopy(resultName, sizeof(resultName), "NotFound");
case FindMap_FuzzyMatch:
strcopy(resultName, sizeof(resultName), "FuzzyMatch");
case FindMap_NonCanonical:
strcopy(resultName, sizeof(resultName), "NonCanonical");
case FindMap_PossiblyAvailable:
strcopy(resultName, sizeof(resultName), "PossiblyAvailable");
}
PrintToServer("FindMap says %s - \"%s\"", resultName, mapName);
return Plugin_Handled;
}