ISource2ModMaps
The current map, the next one, map changes and map lists.
What a map vote, a map chooser or an admin "map" command builds on; none of those are in the core.
A map is named the way the console takes it:
- "de_dust2" -- a map the server has (IsMapValid()), changed to with
changelevel; - "workshop/3070212801" or "3070212801" -- a Workshop map by its ID, changed to with
host_workshop_map; - any other name -- assumed to be a map of the server's Workshop collection, changed to with
ds_workshop_changelevel.
Map lists come from configs/maplists.json, SourceMod's maplists.cfg as JSON:
{
"mapcyclefile": { "file": "mapcycle.txt" }, // relative to the game directory
"default": { "target": "mapcyclefile" }, // another list's name
"mapchooser": { "maps": [ "de_dust2", "workshop/3070212801" ] }
}A list that is not in the file falls back to "default", "default" to "mapcyclefile", and that to mapcycle.txt in the game directory. In a list file every line is a map; empty lines and lines starting with //, # or ; are skipped.
Interface id ISource2ModMaps001 (SOURCE2MOD_MAPS_INTERFACE) · Global g_pSource2ModMaps · Header source2mod/ISource2ModMaps.h
Methods
GetCurrentMap
virtual const char* GetCurrentMap() = 0;The map running now ("de_dust2"); "" before the first one.
IsMapValid
virtual bool IsMapValid(const char* map) = 0;Whether the server has this map (the engine's IsMapValid). Workshop maps that are not downloaded yet are not valid.
| Parameter | Type |
|---|---|
map | const char* |
FindMap
virtual Source2ModFindMapResult FindMap(const char* map, std::string& found) = 0;SourceMod's FindMap: the map a typed name means.
| Parameter | Type | Description |
|---|---|---|
map | const char* | What was typed. |
found | std::string& | Receives the map's full name (or map itself). |
SetNextMap
virtual bool SetNextMap(const char* map) = 0;The map the match moves to when it ends.
Sets the game's nextlevel as well; for a Workshop map the core changes level itself when the match ends (cs_win_panel_match, after mp_match_restart_delay).
| Parameter | Type |
|---|---|
map | const char* |
Returns bool — false for a name FindMap() does not find at all.
GetNextMap
virtual const char* GetNextMap() = 0;The next map: what SetNextMap() set, else the game's nextlevel, else the one after the current map in "mapcyclefile".
Returns const char* — "" when none of those gives one.
ChangeLevel
virtual bool ChangeLevel(const char* map, const char* reason) = 0;Changes the map now (SourceMod's ForceChangeLevel).
| Parameter | Type | Description |
|---|---|---|
map | const char* | A map in any of the forms above. |
reason | const char* | Kept in the map history. |
Returns bool — false for an empty name.
GetMapHistorySize
virtual int GetMapHistorySize() = 0;How many earlier maps the history holds (up to 32).
GetMapHistory
virtual bool GetMapHistory(int index, Source2ModMapHistoryEntry& entry) = 0;An earlier map, 0 = the one before this one. false when out of range.
| Parameter | Type |
|---|---|
index | int |
entry | Source2ModMapHistoryEntry& |
ReadMapList
virtual bool ReadMapList(const char* name, std::vector<std::string>& maps, int flags) = 0;Reads a map list (see the file comment).
| Parameter | Type | Description |
|---|---|---|
name | const char* | The list: "default", "mapcyclefile", or a plugin's own. |
maps | std::vector<std::string>& | The maps are appended here. |
flags | int | Source2ModMapListFlags. |
Returns bool — false when no list could be read (maps is left as it was).
Source2ModMapHistoryEntry
One map that was played, newest first in GetMapHistory().
Fields
| Field | Type | Description |
|---|---|---|
map | std::string | |
reason | std::string | Why the server left it: the reason given to ChangeLevel(), or "Normal level change". |
startTime | int64_t | When it started, Unix time. |
Enums
Source2ModFindMapResult
enum Source2ModFindMapResultSourceMod's FindMapResult, the same numbers.
| Name | Value | Description |
|---|---|---|
SOURCE2MOD_FINDMAP_FOUND | 0 | The server has a map by exactly this name. |
SOURCE2MOD_FINDMAP_NOT_FOUND | 1 | Nothing by this name. |
SOURCE2MOD_FINDMAP_FUZZY_MATCH | 2 | One map of the map lists starts with or contains this name; found holds it. |
SOURCE2MOD_FINDMAP_NON_CANONICAL | 3 | Not used by this core (SourceMod's workshop name normalisation). |
SOURCE2MOD_FINDMAP_POSSIBLY_AVAILABLE | 4 | A Workshop ID or Workshop name: may well exist, cannot be checked before changing. |
Source2ModMapListFlags
enum Source2ModMapListFlagsReadMapList() flags, SourceMod's MAPLIST_FLAG_* values.
| Name | Value | Description |
|---|---|---|
SOURCE2MOD_MAPLIST_MAPSFOLDER | 1 << 0 | When the list cannot be read, every map in the maps folder instead. |
SOURCE2MOD_MAPLIST_NO_DEFAULT | 1 << 2 | Do not fall back to "default" / "mapcyclefile". |