Browse Source

Add initial implementation for map lists

Shtoyan 2 years ago
parent
commit
caa35a67b8
  1. 2
      config/AcediaLauncher.ini
  2. 7
      config/AcediaMaps.ini
  3. 4
      sources/AcediaLauncherMut.uc
  4. 4
      sources/GameModes/GameMode.uc
  5. 75
      sources/MapList/MapList.uc
  6. 25
      sources/MapList/MapList_Feature.uc
  7. 6
      sources/StartUp.uc
  8. 46
      sources/VotingHandlerAdapter.uc

2
config/AcediaLauncher.ini

@ -1,2 +1,2 @@
[AcediaLauncher.Packages]
useGameModes=false
useGameModes=true

7
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"

4
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();
}

4
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)
{
@ -105,6 +106,7 @@ protected function FromData(HashTable source)
gameTypeClass = source.GetString(P("gameTypeClass"));
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"

75
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 <https://www.gnu.org/licenses/>.
*/
class MapList extends FeatureConfig
perObjectConfig
config(AcediaMaps);
var public config array<string> 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"
}

25
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 <https://www.gnu.org/licenses/>.
*/
class MapList_Feature extends Feature;
defaultproperties {
configClass = class'MapList'
}

6
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<Packages.FeatureConfigPair> GetAutoConfigurationInfo()
local array<Packages.FeatureConfigPair> 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();

46
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<string> maps) {
local int i;
local VotingHandler.MapVoteMapList nextRecord;
local array<VotingHandler.MapVoteMapList> 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)
{

Loading…
Cancel
Save