From 7b1ed6ed163d42cf54d8eb23b39310e2ab65d757 Mon Sep 17 00:00:00 2001 From: Shtoyan Date: Tue, 7 Mar 2023 17:08:55 +0400 Subject: [PATCH] Add initial implementation for map lists --- config/AcediaMaps.ini | 7 +++ sources/AcediaLauncherMut.uc | 4 +- sources/GameModes/GameMode.uc | 10 ++-- sources/MapList/MapList.uc | 75 ++++++++++++++++++++++++++++++ sources/MapList/MapList_Feature.uc | 25 ++++++++++ sources/StartUp.uc | 6 ++- sources/VotingHandlerAdapter.uc | 46 +++++++++++++++++- 7 files changed, 167 insertions(+), 6 deletions(-) create mode 100644 config/AcediaMaps.ini create mode 100644 sources/MapList/MapList.uc create mode 100644 sources/MapList/MapList_Feature.uc diff --git a/config/AcediaMaps.ini b/config/AcediaMaps.ini new file mode 100644 index 0000000..c0ed975 --- /dev/null +++ b/config/AcediaMaps.ini @@ -0,0 +1,7 @@ +[default MapList] +autoEnable=true +map="KF-BioticsLab" +map="KF-Farm" +map="KF-Manor" +map="KF-Offices" +map="KF-WestLondon" diff --git a/sources/AcediaLauncherMut.uc b/sources/AcediaLauncherMut.uc index 82ee6ca..9a36456 100644 --- a/sources/AcediaLauncherMut.uc +++ b/sources/AcediaLauncherMut.uc @@ -1,7 +1,8 @@ /** * Main and only Acedia mutator. Used for providing access to mutator * events' calls and detecting server travel. - * Copyright 2020-2022 Anton Tarasenko + * Copyright 2020-2023 Anton Tarasenko + * 2023 Shtoyan *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -45,6 +46,7 @@ simulated function PreBeginPlay() } if (votingAdapter != none) { votingAdapter.InjectIntoVotingHandler(); + votingAdapter.TrySetupMapList(); } SetupMutatorSignals(); } diff --git a/sources/GameModes/GameMode.uc b/sources/GameModes/GameMode.uc index 13589bd..5eeff6e 100644 --- a/sources/GameModes/GameMode.uc +++ b/sources/GameModes/GameMode.uc @@ -77,6 +77,7 @@ protected function HashTable ToData() result.SetString(P("gameTypeClass"), gameTypeClass); result.SetString(P("acronym"), acronym); result.SetString(P("mapPrefix"), mapPrefix); + nextArray = _.collections.EmptyArrayList(); for (i = 0; i < option.length; i += 1) { @@ -103,9 +104,10 @@ protected function FromData(HashTable source) return; } gameTypeClass = source.GetString(P("gameTypeClass")); - acronym = source.GetString(P("acronym")); - mapPrefix = source.GetString(P("mapPrefix")); - nextArray = source.GetArrayList(P("option")); + acronym = source.GetString(P("acronym")); + mapPrefix = source.GetString(P("mapPrefix")); + + nextArray = source.GetArrayList(P("option")); if (nextArray == none) { return; } @@ -271,6 +273,8 @@ defaultproperties hardSynonyms(0) = "harder" // "hard" is prefix of this, so it will count hardSynonyms(1) = "difficult" suicidalSynonyms(0) = "suicidal" + // DONE! + suicidalSynonyms(1) = "sui" hoeSynonyms(0) = "hellonearth" hoeSynonyms(1) = "hellon earth" hoeSynonyms(2) = "hell onearth" diff --git a/sources/MapList/MapList.uc b/sources/MapList/MapList.uc new file mode 100644 index 0000000..f2a5aa0 --- /dev/null +++ b/sources/MapList/MapList.uc @@ -0,0 +1,75 @@ +/** + * Config for `MapList_Feature`. + * Copyright 2023 Anton Tarasenko + * 2023 Shtoyan + *------------------------------------------------------------------------------ + * This file is part of Acedia. + * + * Acedia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License, or + * (at your option) any later version. + * + * Acedia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Acedia. If not, see . + */ +class MapList extends FeatureConfig + perObjectConfig + config(AcediaMaps); + +var public config array map; + +protected function HashTable ToData() { + local int i; + local ArrayList mapArray; + local HashTable result; + + result = _.collections.EmptyHashTable(); + mapArray = _.collections.EmptyArrayList(); + + for (i = 0; i < map.length; i += 1) { + mapArray.AddString(map[i]); + } + + result.SetItem(P("maps"), mapArray); + _.memory.Free(mapArray); + + return result; +} + +protected function FromData(HashTable source) { + local int i; + local ArrayList mapArray; + + if (source == none) { + return; + } + + mapArray = source.GetArrayList(P("maps")); + if (mapArray == none) { + return; + } + + map.length = 0; + for (i = 0; i < mapArray.GetLength(); i += 1) { + map[map.length] = mapArray.GetString(i); + } + _.memory.Free(mapArray); +} + +protected function DefaultIt() { + map[0] = "KF-BioticsLab"; + map[1] = "KF-Farm"; + map[2] = "KF-Manor"; + map[3] = "KF-Offices"; + map[4] = "KF-WestLondon"; +} + +defaultproperties { + configName = "AcediaMaps" +} \ No newline at end of file diff --git a/sources/MapList/MapList_Feature.uc b/sources/MapList/MapList_Feature.uc new file mode 100644 index 0000000..0000ff6 --- /dev/null +++ b/sources/MapList/MapList_Feature.uc @@ -0,0 +1,25 @@ +/** + * This feature is a dumb proxy for loading map list configs. + * Copyright 2023 Anton Tarasenko + * 2023 Shtoyan + *------------------------------------------------------------------------------ + * This file is part of Acedia. + * + * Acedia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License, or + * (at your option) any later version. + * + * Acedia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Acedia. If not, see . + */ +class MapList_Feature extends Feature; + +defaultproperties { + configClass = class'MapList' +} \ No newline at end of file diff --git a/sources/StartUp.uc b/sources/StartUp.uc index 478883d..b9c698d 100644 --- a/sources/StartUp.uc +++ b/sources/StartUp.uc @@ -1,6 +1,7 @@ /** * This actor's role is to perform Acedia's server startup. - * Copyright 2019-2022 Anton Tarasenko + * Copyright 2019-2023 Anton Tarasenko + * 2023 Shtoyan *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -125,6 +126,9 @@ public function array GetAutoConfigurationInfo() local array result; availableFeatures = _.environment.GetAvailableFeatures(); + // We only have a single feature, so instead of adding our own manifest, simply add it here + class'MapList_Feature'.static.LoadConfigs(); + availableFeatures[availableFeatures.length] = class'MapList_Feature'; for (i = 0; i < availableFeatures.length; i += 1) { autoConfig = availableFeatures[i].static.GetAutoEnabledConfig(); diff --git a/sources/VotingHandlerAdapter.uc b/sources/VotingHandlerAdapter.uc index d0538d1..31b491a 100644 --- a/sources/VotingHandlerAdapter.uc +++ b/sources/VotingHandlerAdapter.uc @@ -5,7 +5,8 @@ * data from Acedia's game modes. * Requires `GameInfo`'s voting handler to be derived from * `XVotingHandler`, which is satisfied by pretty much every used handler. - * Copyright 2021-2022 Anton Tarasenko + * Copyright 2021-2023 Anton Tarasenko + * 2023 Shtoyan *------------------------------------------------------------------------------ * This file is part of Acedia. * @@ -102,6 +103,7 @@ protected function Finalizer() * Backup of replaced configs is made internally, so that they can be restored * on map change. */ +// TODO ADD ME! public final function InjectIntoVotingHandler() { local int i; @@ -138,6 +140,48 @@ public final function InjectIntoVotingHandler() votingHandler.gameConfig = newVotingHandlerConfig; } +public function TrySetupMapList() { + local MapList_Feature mapListFeature; + local Text currentConfigName; + local MapList currentConfig; + + warn(">>>>>>>> START!"); + mapListFeature = MapList_Feature(class'MapList_Feature'.static.GetEnabledInstance()); + currentConfigName = mapListFeature.GetCurrentConfig(); + currentConfig = MapList(class'MapList'.static.GetConfigInstance(currentConfigName)); + + ReplaceHandlerMaps(XVotingHandler(votingHandlerReference.Get()), currentConfig.map); +} + +public function ReplaceHandlerMaps(XVotingHandler votingHandler, array maps) { + local int i; + local VotingHandler.MapVoteMapList nextRecord; + local array recordArray; + + if (votingHandler == none) { + warn("votingHandler is none!"); + return; + } + if (maps.length == 0) { + warn("maps.length is 0!"); + return; + } + + recordArray = votingHandler.mapList; + warn(">>> recordArray.length =" $ recordArray.length); + + recordArray.length = maps.length; + votingHandler.mapCount = maps.length; + nextRecord.bEnabled = true; + + for (i = 0; i < maps.length; i += 1) { + nextRecord.mapName = maps[i]; + recordArray[i] = nextRecord; + } + + votingHandler.mapList = recordArray; +} + private function VotingHandler.MapVoteGameConfig BuildVotingHandlerConfig( GameMode gameMode) {