# GDB-style unlimited stadium management - add as many stadiums as you want in a GDB-like folder structure

# Mostly unchanged stadium packaging - stadium structure remains almost identical to the .cpk version, meaning that entire stadium directory tree (starting with "common" folder) can be copy-pasted into one top-level GDB folder. These folders from the usual stadium-related cpk-tree are currently supported:

IMPORTANT: [color=rgb(255,0,0);]db files (commonetc...) for stadium registration are not required. DO NOT INCLUDE THOSE!![/color]​

# Stadium assignment to individual home teams via [font="'Courier New';"]map_teams.txt[/font] file - pretty much self-explanatory, see the supplied [font="'Courier New';"]map_teams.txt[/font] file for examples of how to connect team ID with one GDB-stadium

# Stadium assignment to competitions via [font="'Courier New';"]map_competitions.txt[/font] file - use it to connect competition/tournament ID with one or more stadiums from GDB.All teams participating in particular competition can either use identical stadium (if ony one stadium is assigned to that competition) [color=#59b300;]or have one of the stadiums assigned randomly (v1.1 feature) if there's more than one stadium assigned to that competition.[/color]

[color=#000000;]## [/color][color=#59b300;]v1.1[/color][color=#000000;] - It is possible to assign unlimited number of stadiums to the same competition[/color] - in this case, ONE RANDOM stadium will be selected for every home team that:

participates in that competition, BUT

DOES NOT have individual stadium assigned in [font="'Courier New';"]map_teams.txt[/font] file

[color=rgb(255,0,0);]IMPORTANT:[/color][color=rgb(255,0,0);] by default, competition assignment would always take priority over team assignment in any game mode, but that can be easily configured within .lua script.[/color]To override this default behavior you have to slightly modify StadiumServer.lua script itself - add/remove competition IDs in [font="'Courier New';"]override_competitions[/font] table, thus defining more or less competitions where individual team assignments from [font="'Courier New';"]map_teams.txt[/font] takes priority over competition assignment from [font="'Courier New';"]map_competitions.txt[/font][color=rgb(89,179,0);]Since v1.1, because of newly introduced random stadium selection option for competitions, [font="'Courier New';"]override_competitions[/color] table has been vastly increased to include all exhibition, league and league-cup matches[/font] - you can keep individual stadiums for those teams that already have one in [font="'Courier New';"]map_teams.txt[/font], while all the other teams without individual stadium would get randomly selected stadium from [font="'Courier New';"]map_competitions.txt[/font]

## Support for optional stadium to be used in final match of the competition only - again, pretty much self-explanatory. See [font="'Courier New';"]map_competitions.txt[/font] file for more details

[color=#59b300;]v1.1 - CAUTION:[/color] if multiple stadiums are assigned to a single competition and you want to use specific stadium for finals, then you must include stadium for final match IN EVERY stadium assignment

# Exhibition mode behavior [color=#00b300;][v1.3][/color] - stadium assignment logic has been refined to be more in-line with the usual game behavior:

[color=#ff0000;]IMPORTANT CHANGE: Stadium server will be active in exhibition mode[/color] ONLY if you have selected either "Home ground" or "Random" setting. This enables you to use any stadium from your .cpk pack and additional stadium server's stadiums side by side.

"Random" setting in exhibition mode is going to select stadium either from your .cpk pack or from stadium server's repository.

Complementing this change, additional lua table is available, to customize which teams should keep their .cpk+EDIT assigned home grounds (e.g. Barcelona -> Konami's Camp Nou, Team X -> Stadium X from your .cpk, etc.). See this post for an example.

# Correct stadium previews and stadium names - displayed in game menus (where available, depending on game mode) and scoreboards

# Support for replay mode [color=#00b300;][v1.3][/color]

# Stadium server is deactivated in edit mode

Current limitations/issues:

1. adboards handling - by default, stadium server will load commonbgmodelbgbill related files (including config.xml!!) if they exist within custom stadium files. If you'd like to use your already configured .cpk adboards packs, you can comment-out single line of code in StadiumServer.lua to disable adboards serving (see the code, it is noted where that line of code is)

2.[color=rgb(255,0,0);]IMPORTANT: cooperation with other .lua scripts that use "set_stadium" event[/color] - unfortunately, because of the way the stadiums are structured and handled by the game, it was necessary for StadiumServer.lua to use set_stadium event to force the game to use the exact stadium ID of the new stadium, in order to load all the files that belong to that stadium. Another approach, which would not "steal" set_stadium event (i.e. trying to override the files of any stadium that the game would like to use) did not prove successful, because stadiums simply are not file-for-file compatible, causing various artifacts when trying to replace e.g. stadium using ID 016 with custom stadium using any other ID

Bottom-line - if you want StadiumServer to work, you must not use any other .lua scripts that use set_stadium event to change stadium_id

you can still use additional .lua scripts to modify stadium conditions (day/night, weather, summer/winter) by using newly introduced set_conditions event (see Sider 3.3.4 release notes) - just to be on the safe side of the story, place your set_conditions related scripts below StadiumServer.lua in sider.ini

3. Not always accurate stadium selection during saved replays playback [color=#00b300;][v1.3][/color] - saved replay files do not store tournament_id info. If the stadium used in saved replay has been assigned via [font="'Courier New';"]map_competitions.txt[/font], then it is not possible for stadium server to make accurate re-selection of that particular stadium during replay playback.

Recommended way to re-pack stadiums that are available in .cpk files

Although extracted stadium packs may work without any problems, I'd recommend to use only one stadium per folder in [font="'Courier New';"]contentstadium-server[/font].

It is recommended to remove any files that are not directly related to stadium (especially commonetc... files)

1. Fix for replay mode - there should be no more infinite loads. Some stadium is going to be selected - sometimes it will not be the one that was used while saving the replay, but one of the available stadiums will be selected - either by the stadium server or by the sider itself (ultimate "safety net", which selects the first available .cpk stadium in situations where stadium server fails to find any match for the stadium ID used in replay). Why is it not possible to make more accurate selection? Because tournament_ID is not saved in replay files. Game over.

2. Changed stadium assignment logic for exhibition modes onlySince sider 3.4.0 introduced [font="'Courier New';"]ctx.stadium_choice[/font] field, which can be used in exhibition mode to check if user has selected "Home ground" or "Random" option in "Stadium menu", stadium assignment logic has been refined to be more in-line with the usual game behavior:

THE MOST IMPORTANT CHANGE: Stadium server will be active in exhibition mode ONLY if you have selected either "Home ground" or "Random" setting. If these are NOT selected, then stadium server is no longer "replacing" every stadium with the new one. This enables you to use any stadium from your .cpk pack if you want to (simply select it in stadium menu) and additional stadium server's stadiums side by side.

"Random" setting in exhibition mode is going to select stadium either from your .cpk pack or from stadium server's repository

3. Additional customizable lua table is added to the script - so that you can customize which teams should keep using their .cpk+EDIT00000000 assigned home grounds (e.g. Barcelona -> Konami's Camp Nou, Team X -> Stadium X from your .cpk, etc.) - a.k.a. "exclusive .cpk home grounds table"

1. Fix for replay mode - there should be no more infinite loads. Some stadium is going to be selected - sometimes it will not be the one that was used while saving the replay, but one of the available stadiums will be selected - either by the stadium server or by the sider itself (ultimate "safety net", which selects the first available .cpk stadium in situations where stadium server fails to find any match for the stadium ID used in replay). Why is it not possible to make more accurate selection? Because tournament_ID is not saved in replay files. Game over.

2. Changed stadium assignment logic for exhibition modes onlySince sider 3.4.0 introduced [font="'Courier New';"]ctx.stadium_choice[/font] field, which can be used in exhibition mode to check if user has selected "Home ground" or "Random" option in "Stadium menu", stadium assignment logic has been refined to be more in-line with the usual game behavior:

[*]THE MOST IMPORTANT CHANGE: Stadium server will be active in exhibition mode ONLY if you have selected either "Home ground" or "Random" setting. If these are NOT selected, then stadium server is no longer "replacing" every stadium with the new one. This enables you to use any stadium from your .cpk pack if you want to (simply select it in stadium menu) and additional stadium server's stadiums side by side.[*]"Random" setting in exhibition mode is going to select stadium either from your .cpk pack or from stadium server's repository[/list]3. Additional customizable lua table is added to the script - so that you can customize which teams should keep using their .cpk+EDIT00000000 assigned home grounds (e.g. Barcelona -> Konami's Camp Nou, Team X -> Stadium X from your .cpk, etc.) - a.k.a. "exclusive .cpk home grounds table"