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.

ParameterType
mapconst char*

FindMap

virtual Source2ModFindMapResult FindMap(const char* map, std::string& found) = 0;

SourceMod's FindMap: the map a typed name means.

ParameterTypeDescription
mapconst char*What was typed.
foundstd::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).

ParameterType
mapconst 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).

ParameterTypeDescription
mapconst char*A map in any of the forms above.
reasonconst 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.

ParameterType
indexint
entrySource2ModMapHistoryEntry&

ReadMapList

virtual bool ReadMapList(const char* name, std::vector<std::string>& maps, int flags) = 0;

Reads a map list (see the file comment).

ParameterTypeDescription
nameconst char*The list: "default", "mapcyclefile", or a plugin's own.
mapsstd::vector<std::string>&The maps are appended here.
flagsintSource2ModMapListFlags.

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

FieldTypeDescription
mapstd::string
reasonstd::stringWhy the server left it: the reason given to ChangeLevel(), or "Normal level change".
startTimeint64_tWhen it started, Unix time.

Enums

Source2ModFindMapResult

enum Source2ModFindMapResult

SourceMod's FindMapResult, the same numbers.

NameValueDescription
SOURCE2MOD_FINDMAP_FOUND0The server has a map by exactly this name.
SOURCE2MOD_FINDMAP_NOT_FOUND1Nothing by this name.
SOURCE2MOD_FINDMAP_FUZZY_MATCH2One map of the map lists starts with or contains this name; found holds it.
SOURCE2MOD_FINDMAP_NON_CANONICAL3Not used by this core (SourceMod's workshop name normalisation).
SOURCE2MOD_FINDMAP_POSSIBLY_AVAILABLE4A Workshop ID or Workshop name: may well exist, cannot be checked before changing.

Source2ModMapListFlags

enum Source2ModMapListFlags

ReadMapList() flags, SourceMod's MAPLIST_FLAG_* values.

NameValueDescription
SOURCE2MOD_MAPLIST_MAPSFOLDER1 << 0When the list cannot be read, every map in the maps folder instead.
SOURCE2MOD_MAPLIST_NO_DEFAULT1 << 2Do not fall back to "default" / "mapcyclefile".

On this page