Advanced Map Configuration
Recently I decided I wanted to run multiple server instances of Left 4 Dead, each with different settings, including map-specific settings. Without having multiple installs. Preferably using -fork.
That doesn't work well without a really convoluted alias setup, let me tell you.
This plugin fixes that. On each map load (in OnConfigsExecuted) the plugin runs through a series of configuration files, all stored in cfg/advmap/, based on various things it can see about the server. If any of the files is not there it skips it.
Assuming you are on a Left 4 Dead server on the l4d_vs_hospital01_apartment map, the full list it will look for by default is over 40 entries long. The basics, however, are the following files in the various folders it is checking:
default.cfg
l4d.cfg
vs.cfg
hospital01.cfg
l4d_.cfg
l4d_vs_.cfg
l4d_vs_hospital01_.cfg
l4d_vs_hospital01_apartment.cfg
AKA, a default configuration file, a configuration file for each prefix on the map filename individually, the complete prefix set in order, and the map name itself. The catch is it looks in the following folders for each of those files by default:
cfg/advmap/<gamemode?/>
cfg/advmap/<gamemode?/>/<ip>/
cfg/advmap/<gamemode?/>/<hostip>/
cfg/advmap/<gamemode?/>/<hostport>/
cfg/advmap/<gamemode?/>/<ip>/<hostport>/
cfg/advmap/<gamemode?/>/<hostip>/<hostport>/
Where ip, hostip, and port are the cvars ip, hostip, and port.
gamemode (sm_mapconfig_gamemode) is included when set so you can cut out the ip, hostip, and hostport checks but still have multiple named "modes" of play.
Configuration:
sm_mapconfig_enabled - Default 1 - Is the plugin enabled at all? If set to 0 no attempt to run additional configs will be made.
sm_mapconfig_prefixchar - Default "_" - I doubt this will ever need to be changed, but figured it was better to make it an option.
sm_mapconfig_prefixdepth - Default 3 - Maximum number of prefixes to extract from the map filename
sm_mapconfig_prefixmode - Default 3 - Bitmask.
- 0 - Nothing set, prefix checking is disabled entirely.
- 1 - Run prefix configs based on entire prefix to point. (with trailing prefixchar)
- 2 - Run prefix configs based on pieces of prefix. (no trailing prefixchar)
- 4 - Remove trailing digits from last prefix before adding prefixchar (Only with 1)
- 8 - Reverse order of prefix configs. (Only with 2)
- 16 - Run prefix configs ONLY, no map configs. If you set ONLY this (or this and 4 and/or you won't get prefix OR map configs.
sm_mapconfig_includeport - Default 1 - Do we include the port in the folder tree when checking for map config files?
- 0 - Never
- 1 - Run configs that match without first, then with
- 2 - Only run configs that match with
sm_mapconfig_includeip - Default 6 - Bitmask. Do we include the ip in the folder tree when checking for map config files?
- 0 - Never
- 1 - Only run configs that match with (if not set, run configs that match without first, then with)
- 2 - Use cvar "ip" - Which, incidently, may or may not be an ip
- 4 - Use cvar "hostip" - Which appears to always be the decimal (not dotted quad) form of the ip
sm_mapconfig_gamemode - Default "" - A folder name to check for config files in. If changed in one of the config files the plugin runs it takes effect on the next map load. If changed at any other point it triggers the configuration reload right away, as if the map had just changed.
sm_mapconfig_version - The version of the plugin.
Notes:
I HIGHLY recommend disabling some of the folders unless you need them. You should not, for example, need the ip, hostip, AND hostport options active all the time. I personally plan on running with just the hostport option active, and only so that it can disable the hostport option and activate a gamemode.
Alternatively, if you want to use the ip, hostip, or hostport options, consider enabling the "require" them options so that the tree will not be checked above them.
Tricks:
If the prefix mode includes bits 4 and 1 (such as if you set it to 5) then Left 4 Dead campaigns can be easily targeted, as it will run the following campaign specific configs:
l4d_airport_.cfg
l4d_farm_.cfg
l4d_hospital_.cfg
l4d_smalltown_.cfg
l4d_vs_farm_.cfg
l4d_vs_hospital_.cfg