Maplists and how to manage them

Maplists and how to manage them

SpringRTS Perl Autohost for Dedicated Server

Moderators: Moderators, Lobby Developers, SPADS AutoHost

Post Reply
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Maplists and how to manage them

Post by Jools »

I just recently discovered that there is a maplists.conf file, and I haven't used it at all.

I understand that you define the name of the list and what maps it contains. But is it possible to add maps to those lists on the fly? I think not. Or did I miss something?

Do you want me to make a plugin that handles it? It would take me less time than wade through 1811 maps and decide which belongs to a list. And it would also produce better results.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Maplists and how to manage them

Post by bibim »

Jools wrote:I just recently discovered that there is a maplists.conf file, and I haven't used it at all.

I understand that you define the name of the list and what maps it contains.
Yes, as indicated in the mapList setting documentation, this file is used to define the map lists. These map lists can then be used as values for the mapList setting (to configure the main map list, which specifies which maps are allowed on the autohost), and as <subMapList> value for the rotationType setting (to configure the rotation map list, which specifies which maps of the main map list are used for automatic rotation).

Each entry in this file is actually a regular expression filter. If the map name matches the regular expression, it is included in the map list. If it doesn't, next filter is tried. If it didn't match any filter in the map list definition, then it is excluded from the map list.
If a filter starts with "!", then the filter logic is inversed. It means that if the map name matches the regular expression following the "!", then it is excluded from the map list, else next filter is tried.
So as soon as you start combining normal and inversed regular expression filters in a map list definition, the filter order is important.
Additionally, a special value "_GHOSTMAPS_" can be used, it matches all ghost maps (so according to rules above, "!_GHOSTMAPS_" will exclude all ghost maps and keep only local maps).
Jools wrote:But is it possible to add maps to those lists on the fly? I think not. Or did I miss something?
If by "add maps to those lists on the fly" you mean add them in a persistent way through commands while SPADS is running, then no it's not possible. This file follows the same logic as all SPADS config files: if you want to alter SPADS configuration in a persistent way you have to edit the configuration files manually. The main reason for this is that SPADS configuration system is very flexible, allowing config files includes, configuration macros (to define settings at SPADS launch time) etc. So you can't even be sure that the actual map lists definitions are all in the mapLists.conf file for a given SPADS installation.
However, for simple SPADS configurations which use a simple mapLists.conf file, it is possible to implement automatic modification of this file, yes.
Jools wrote:Do you want me to make a plugin that handles it? It would take me less time than wade through 1811 maps and decide which belongs to a list. And it would also produce better results.
I wouldn't say I want you to make such a plugin. But if you think it would be useful to you, then there are chances it could be useful to others too so feel free to do it, yes :wink:
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Maplists and how to manage them

Post by Jools »

Yes, that's what I meant.

The main problem is reading and writing to config files: I tried some packages like Config::Tiny and Config::IniFiles but they fail (presumably) because the lines in mapLists.conf don't end with ;

Example: Syntax error at line 2: '.*'

Since spads already has an "Object-oriented Perl module handling SPADS configuration files" I wondered if I could use that instead, and specifically withing that the method "loadSimpleTableFile". But it requires to be fed some additional parameters like a log file and a macros variable. I tried to create empty such objects but didn't immediately succeed with that .

Of course I can create own config files in a format is the simple ini-style format, but I think it would be better to make it use the already existing files.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Maplists and how to manage them

Post by bibim »

Jools wrote:Since spads already has an "Object-oriented Perl module handling SPADS configuration files" I wondered if I could use that instead, and specifically withing that the method "loadSimpleTableFile". But it requires to be fed some additional parameters like a log file and a macros variable. I tried to create empty such objects but didn't immediately succeed with that.
If you really want to reload the mapLists.conf file, you can borrow the log object and the macros object of the SpadsConf module to call this loadSimpleTableFile function. You can get them like this for example:

Code: Select all

my $spadsConf=getSpadsConfFull();
my ($spadsConfLog,$spadsConfMacros)=($spadsConf->{log},$spadsConf->{macros});
But actually you shouldn't need to reload the mapLists.conf file, as it has already been loaded by SPADS at startupt. The corresponding data is already available in memory. You can directly access it and perform a local copy of it to modify it as you want, like this for example:

Code: Select all

my $spadsConf=getSpadsConfFull();
my $p_myMapLists=dclone($spadsConf->{mapLists});
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Maplists and how to manage them

Post by Jools »

bibim wrote: But actually you shouldn't need to reload the mapLists.conf file, as it has already been loaded by SPADS at startupt. The corresponding data is already available in memory. You can directly access it and perform a local copy of it to modify it as you want, like this for example:

Code: Select all

my $spadsConf=getSpadsConfFull();
my $p_myMapLists=dclone($spadsConf->{mapLists});
Does that create a hashref or arrayref to the maplist that spads has in memory? Or does it completely clone it? Since it's a scalar I assume it's a reference. But does that then update the maplist that is saved in maplists.conf when the autohost restarts? Sorry this is probably stupid question again but isn't the idea of cloning that you make a copy of something and not manipulate the original.

Edit: I found out with ref function that it returns a hash. It's just that the structure of the conf file looked more like an array; no key/value pairs.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Maplists and how to manage them

Post by bibim »

The data structure for SPADS map lists is a hash indexed by map list names and containing arrayrefs of the corresponding filters.
dclone completely clones the data, which is a good thing when you want to work with SPADS data (removing/adding some maps) without altering the running instance.
Jools wrote:does that then update the maplist that is saved in maplists.conf when the autohost restarts?
No, as I said concerning all SPADS config files: currently if you want to alter SPADS configuration in a persistent way you have to edit the configuration files manually. In other words, currently there is no system in SPADS to modify config files automatically from data in memory. Consequently there is no point in altering the mapList data used by SPADS directly in memory here, unless you just want to alter the currently running SPADS instance. But this won't save the data for you in the mapLists.conf file, there is no code for that in SPADS and you have to write your own.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Maplists and how to manage them

Post by Jools »

As always things are more complicated than you think beforehand, but now I managed to complete this. Still, it was faster than doing everything manually :)

Synopsis:

Categorise your maps in lists such as '1v1', 'popular', 'newbie', etc... Maps can be added to these lists from battleroom. Removal works so and so, the remove command works on maps added on the fly but it does not remove pre-configured maps. Still, this is not so hard to do manually by editing mapLists.conf.

It edits the conf-file in etcDir, so make sure you have write permissions to it. I know this is against best practices, but I wanted to avoid having multiple config files and also having one readable by humans. Before saving the updated config file, it reloads it to see if other autohosts have made any updates to it.

The maplists themselves can be managed as usual with core spads mapList command

[ManageMaps]
This plugin allows users to add and remove maps to/from maplists on the fly.

[addmap]
!addmap <listname>
!addmap 1v1 - adds current map the 1v1 list


[removemap]
!removemap <listname> [<map>]
!removemap 1v1 - removes current map from the 1v1 list
!removemap all - removes current map from all lists


[savemaplist]
!savemaplist - saves the map lists to disk

[printmaplist]
!printmaplist <listname>
!printmaplist <2v2> - prints maps in 2v2 list

raaar
Metal Factions Developer
Posts: 1094
Joined: 20 Feb 2010, 12:17

Re: Maplists and how to manage them

Post by raaar »

I'm having an issue managing map lists through the mapLists.conf file. Some maps aren't shown as available despite being listed in mapLists.conf and having the file in the spring maps directory. This is after placing the files, editing the .conf and restarting spads several times.

Example (missing maps highlighted in red):

- mapLists.conf
rui@rui-Satellite-A300:~/Desktop/maps$ cat ~/spadsInstaller/etc/mapLists.conf
[all]
.*

[approved]
Ravaged_v2
Barren
Altair_Crossing_v3
Rapids_v1
DryRiver
TitanDuel
Victoria Crater v2.1
Icy_Shell_v01
Intersection_v3
Sands of Time v1.0
AlienDesert
Archers_Valley_v6
BarracudaBay
Eye_Of_Horus_v2
SapphireShores_V2.1
SapphireShores_Dry_V2.1
Comet Catcher Redux v2
Ganymede v1
SplinteredTropicsDryV2
Tangerine
Small Supreme Battlefield V2
Kappa_Basin
Tempest Siege v1
Emain Macha v3
DesertSiege_v2b
FrozenFortress_v2
SapphireShores_Duo_V2.1
TheRockJungle_Fix2
Tabula-v6.1




- spring maps directory
rui@rui-Satellite-A300:~/Desktop/maps$ ls -la /home/rui/.spring/maps/
total 643460
drwxrwxrwx 2 rui rui 4096 Oct 24 20:59 .
drwxrwxrwx 13 rui rui 4096 Aug 23 23:11 ..
-rw-rw-r-- 1 rui rui 37997535 Sep 13 22:15 akilon_wastelands_-_v15.sd7
-rwxrwxrwx 1 root root 8075299 Feb 16 2014 AlienDesert.sd7
-rw-rw-r-- 1 rui rui 12048871 Aug 26 05:14 altair_crossing_v3.sd7
-rw-rw-r-- 1 rui rui 20373087 Oct 24 20:59 archers_valley_v6.sd7
-rw-rw-r-- 1 rui rui 7505538 Aug 26 05:20 barracudabay.sd7
-rw-rw-r-- 1 rui rui 2870349 Aug 24 04:22 barren.sd7
-rw-rw-r-- 1 rui rui 30034145 Sep 13 22:17 battle_for_planet_xiv_-_v02.sd7
-rw-rw-r-- 1 rui rui 36204825 Aug 24 02:28 comet_catcher_redux_v2.sd7
-rw-rw-r-- 1 rui rui 17799250 Sep 13 21:51 deltasiege.sd7
-rw-rw-r-- 1 rui rui 29015787 Aug 25 05:28 desertsiege_v2b.sd7
-rw-rw-r-- 1 rui rui 11947587 Sep 13 21:52 dryriver.sd7
-rw-rw-r-- 1 rui rui 22735416 Aug 25 05:25 emain_macha_v3.sd7
-rw-rw-r-- 1 rui rui 18236301 Sep 12 06:29 eye_of_horus_v2.sd7
-rw-rw-r-- 1 rui rui 35312909 Aug 25 05:38 ganymede_v1.sd7
-rw-rw-r-- 1 rui rui 15560543 Sep 13 22:19 glacies_1.3.sd7
-rw-rw-r-- 1 rui rui 10016032 Oct 24 18:50 icy_shell_v01.sd7
-rw-rw-r-- 1 rui rui 7999089 Oct 24 18:50 intersection_v3.sd7
-rw-rw-r-- 1 rui rui 19260170 Sep 12 06:53 kappa_basin.sd7
-rw-rw-r-- 1 rui rui 28138451 Aug 25 05:22 koom_gorge_v1.sd7
-rw-rw-r-- 1 rui rui 780229 Aug 23 23:12 metalheckv2.sdz
-rw-rw-r-- 1 rui rui 7816709 Sep 12 06:42 rapids_v1.sd7
-rw-rw-r-- 1 rui rui 15268200 Aug 25 03:51 ravaged_v2.sd7
-rw-rw-r-- 1 rui rui 1416923 Oct 24 18:50 sands_of_time_v1.0.sd7
-rw-rw-r-- 1 rui rui 21385094 Sep 12 06:22 sapphireshores_dry_v2.1.sd7
-rw-rw-r-- 1 rui rui 36536291 Sep 12 06:23 sapphireshores_duo_v2.1.sd7
-rw-rw-r-- 1 rui rui 21352646 Sep 12 06:23 sapphireshores_v2.1.sd7
-rw-rw-r-- 1 rui rui 15524363 Aug 26 05:30 small_supreme_battlefield_v2.sd7
-rw-rw-r-- 1 rui rui 23598731 Sep 12 06:48 splinteredtropicsdryv2.sd7
-rw-rw-r-- 1 rui rui 29201238 Aug 25 05:35 tabula-v6.1.sd7
-rw-rw-r-- 1 rui rui 18092794 Aug 26 05:22 tangerine.sd7
-rw-rw-r-- 1 rui rui 11127000 Sep 12 06:45 tempest_siege_v1.sd7
-rw-rw-r-- 1 rui rui 37530450 Aug 25 05:33 therockjungle_fix2.sd7
-rw-rw-r-- 1 rui rui 11585368 Oct 24 19:01 TitanDuel.sd7
-rw-rw-r-- 1 rui rui 26379762 Sep 12 06:28 tundra.sdz
-rw-rw-r-- 1 rui rui 10097607 Aug 25 05:23 victoria_crater_v2.1.sd7



- map list on the nebula autohost (response put of !list maps)

[03:26:54] <nebula1> ********** Available maps for current map list **********
[03:26:54] <nebula1> 1. AlienDesert
[03:26:54] <nebula1> 2. Altair_Crossing_v3
[03:26:54] <nebula1> 3. BarracudaBay
[03:26:54] <nebula1> 4. Barren
[03:26:54] <nebula1> 6. Comet Catcher Redux v2
[03:26:54] <nebula1> 8. DesertSiege_v2b
[03:26:54] <nebula1> 10. Emain Macha v3
[03:26:54] <nebula1> 11. Eye_Of_Horus_v2
[03:26:54] <nebula1> 12. Ganymede v1
[03:26:54] <nebula1> 14. Icy_Shell_v01
[03:26:54] <nebula1> 15. Intersection_v3
[03:26:54] <nebula1> 16. Kappa_Basin
[03:26:54] <nebula1> 20. Rapids_v1
[03:26:54] <nebula1> 21. Ravaged_v2
[03:26:54] <nebula1> 22. Sands of Time v1.0
[03:26:54] <nebula1> 23. SapphireShores_Dry_V2.1
[03:26:54] <nebula1> 24. SapphireShores_Duo_V2.1
[03:26:54] <nebula1> 25. SapphireShores_V2.1
[03:26:54] <nebula1> 26. Small Supreme Battlefield V2
[03:26:54] <nebula1> 27. SplinteredTropicsDryV2
[03:26:54] <nebula1> 28. Tabula-v6.1
[03:26:54] <nebula1> 29. Tangerine
[03:26:54] <nebula1> 30. Tempest Siege v1
[03:26:54] <nebula1> 31. TheRockJungle_Fix2
[03:26:54] <nebula1> 34. Victoria Crater v2.1
[03:26:54] <nebula1> ******************** End of map list ********************
[03:26:54] <nebula1> --> Use "!map <mapName_OR_mapNumber>" to change current map.
[03:26:54] <nebula1> --> Use "!set mapList <mapListName>" to change current map list.



Just did some last minute testing using springlobby on the same machine where the SPADS is running and creating a game on dry river and on archers valley, and they work.

After doing that, TitanDuel and Archers Valley v6 now show up on the list in the autohost (DryRiver still doesn't, despite having started a game on it through the springlobby).

Confusing.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Maplists and how to manage them

Post by bibim »

When you set map list to "all", are you able to switch to these "missing" maps?
What is the value of your SpringDataDir setting?

(btw you don't need to restart SPADS, you can either do !reloadArchives if you add maps into your Spring data directory, or !reloadConf if you alter SPADS configuration)
raaar
Metal Factions Developer
Posts: 1094
Joined: 20 Feb 2010, 12:17

Re: Maplists and how to manage them

Post by raaar »

springDataDir:/home/rui/.config/spring/

changed map list to "all" : DryRiver shows up
changed map list to "small" : DryRiver also shows up
changed map list to "approved" : DryRiver does not show up

but then I edited mapLists.conf, deleted/reinserted the line break between DryRiver and the next map on the "approved" list and now it shows up as well. Maybe had an invisible character on that line screwing up the matching.
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Maplists and how to manage them

Post by bibim »

raaar wrote:but then I edited mapLists.conf, deleted/reinserted the line break between DryRiver and the next map on the "approved" list and now it shows up as well. Maybe had an invisible character on that line screwing up the matching.
Yeah, certainly.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Maplists and how to manage them

Post by Jools »

Check dos/unix line endings?
raaar
Metal Factions Developer
Posts: 1094
Joined: 20 Feb 2010, 12:17

Re: Maplists and how to manage them

Post by raaar »

apparently that was it : spads won't process mapLists with windows CRLF line terminators properly.

- after running "unix2dos etc/mapLists.conf"

after !reloadConf, "!list maps" shows
"01:50:59] <nebula1> No map found"

- after running "dos2unix etc/mapLists.conf"

after !reloadConf, "!list maps" shows
[01:53:43] <nebula1> ********** Available maps for current map list **********
[01:53:43] <nebula1> 1. AlienDesert
(...)
(30 something maps)
User avatar
bibim
Lobby Developer
Posts: 952
Joined: 06 Dec 2007, 11:12

Re: Maplists and how to manage them

Post by bibim »

raaar wrote:apparently that was it : spads won't process mapLists with windows CRLF line terminators properly.
It's not exactly that, otherwise SPADS would be very annoying to configure on Windows.

SPADS just processes line terminators according to the system it's running on: it expects LF on Unix, and CRLF on Windows. Anything else is processed as data.
Post Reply

Return to “SPADS AutoHost”