plugins/include/sourcemod.inc
changeset 1738 cb3be0b31d99
parent 1732 569be09534d1
child 1739 6a3e4df7467b
     1.1 --- a/plugins/include/sourcemod.inc	Sun Dec 02 02:05:55 2007 +0000
     1.2 +++ b/plugins/include/sourcemod.inc	Sun Dec 02 02:10:37 2007 +0000
     1.3 @@ -490,6 +490,70 @@
     1.4   */
     1.5  forward OnLibraryRemoved(const String:name[]);
     1.6  
     1.7 +#define MAPLIST_FLAG_MAPSFOLDER		(1<<0)		/**< On failure, use all maps in the maps folder. */
     1.8 +#define MAPLIST_FLAG_CLEARARRAY		(1<<1)		/**< If an input array is specified, clear it before adding. */
     1.9 +#define MAPLIST_FLAG_NO_DEFAULT		(1<<2)		/**< Do not read "default" or "mapcyclefile" on failure. */
    1.10 +
    1.11 +/**
    1.12 + * Loads a map list to an ADT Array.
    1.13 + *
    1.14 + * A map list is a list of maps from a file.  SourceMod allows easy configuration of 
    1.15 + * maplists through addons/sourcemod/configs/maplists.cfg.  Each entry is given a 
    1.16 + * name and a file (for example, "rtv" => "rtv.cfg"), or a name and a redirection 
    1.17 + * (for example, "rtv" => "default").  This native will read a map list entry, 
    1.18 + * cache the file, and return the list of maps it holds.  
    1.19 + *
    1.20 + * Serial change numbers are used to identify if a map list has changed.  Thus, if 
    1.21 + * you pass a serial change number and it's equal to what SourceMod currently knows 
    1.22 + * about the map list, then SourceMod won't reparse the file.
    1.23 + *
    1.24 + * If the maps end up being read from the maps folder (MAPLIST_FLAG_MAPSFOLDER), they 
    1.25 + * are automatically sorted in alphabetical, ascending order.
    1.26 + *
    1.27 + * @param array			Array to store the map list.  If INVALID_HANDLE, a new blank 
    1.28 + *						array will be created.  The blocksize should be at least 16; 
    1.29 + *						otherwise results may be truncated.  Items are added to the array 
    1.30 + *						as strings.  The array is never checked for duplicates, and it is 
    1.31 + *						not read beforehand.  Only the serial number is used to detect 
    1.32 + *						changes.
    1.33 + * @param str			Config name, or "default" for the default map list.  Config names 
    1.34 + *						should be somewhat descriptive.  For example, the admin menu uses 
    1.35 + *						a config name of "admin menu".  The list names can be configured 
    1.36 + *						by users in addons/sourcemod/configs/maplists.cfg.
    1.37 + * @param serial		Serial number to identify last known map list change.  If -1, the 
    1.38 + *						the value will not be checked.  If the map list has since changed, 
    1.39 + *						the serial is updated (even if -1 was passed).  If there is an error 
    1.40 + *						finding a valid maplist, then the serial is set to -1.
    1.41 + * @param flags			MAPLIST_FLAG flags.
    1.42 + * @return				On failure:
    1.43 + *						 INVALID_HANDLE is returned, the serial is set to -1, and the input 
    1.44 + *						 array (if any) is left unchanged.
    1.45 + *						On no change:
    1.46 + 						 INVALID_HANDLE is returned, the serial is unchanged, and the input 
    1.47 + 						 array (if any) is left unchanged.
    1.48 + *						On success:
    1.49 + *						 A valid array Handle is returned, containing at least one map string.  
    1.50 + *						 If an array was passed, the return value is equal to the passed Array 
    1.51 + *						 Handle.  If the passed array was not cleared, it will have grown by at 
    1.52 + *						 least one item.  The serial number is updated to a positive number.
    1.53 + * @error				Invalid array Handle that is not INVALID_HANDLE.
    1.54 + */
    1.55 +native Handle:ReadMapList(Handle:array=INVALID_HANDLE,
    1.56 +						  &serial=-1,
    1.57 +						  const String:str[]="default",
    1.58 +						  flags=MAPLIST_FLAG_CLEARARRAY);
    1.59 +						  
    1.60 +/**
    1.61 + * Makes a compatibility binding for map lists.  For example, if a function previously used 
    1.62 + * "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that 
    1.63 + * will be overridden if it's in the maplists.cfg file.
    1.64 + *
    1.65 + * @param name			Configuration name that would be used with ReadMapList().
    1.66 + * @param file			Default file to use.
    1.67 + * @noreturn
    1.68 + */
    1.69 +native SetMapListCompatBind(const String:name[], const String:file[]);
    1.70 +
    1.71  #include <helpers>
    1.72  #include <entity>
    1.73