Browse Source

Change to adapt to AcediaCore's changes

develop
Anton Tarasenko 2 years ago
parent
commit
a026b731ee
  1. 90
      sources/GameModes/BaseGameMode.uc
  2. 68
      sources/GameModes/GameMode.uc

90
sources/GameModes/BaseGameMode.uc

@ -54,80 +54,82 @@ var protected config array<FeatureConfigPair> includeFeatureAs;
var private LoggerAPI.Definition warnBadMutatorName, warnBadFeatureName; var private LoggerAPI.Definition warnBadMutatorName, warnBadFeatureName;
protected function AssociativeArray ToData() protected function HashTable ToData()
{ {
local int i; local int i;
local AssociativeArray result; local HashTable result;
local AssociativeArray nextPair; local HashTable nextPair;
local DynamicArray nextArray; local ArrayList nextArray;
result = _.collections.EmptyAssociativeArray();
result.SetItem(P("title"), _.text.FromFormattedString(title)); result = _.collections.EmptyHashTable();
result.SetItem(P("difficulty"), _.text.FromString(difficulty)); result.SetFormattedString(P("title"), title);
nextArray = _.collections.EmptyDynamicArray(); result.SetString(P("difficulty"), difficulty);
nextArray = _.collections.EmptyArrayList();
for (i = 0; i < includeFeature.length; i += 1) { for (i = 0; i < includeFeature.length; i += 1) {
nextArray.AddItem(_.text.FromString(includeFeature[i])); nextArray.AddString(includeFeature[i]);
} }
result.SetItem(P("includeFeature"), nextArray); result.SetItem(P("includeFeature"), nextArray);
nextArray = _.collections.EmptyDynamicArray(); _.memory.Free(nextArray);
nextArray = _.collections.EmptyArrayList();
for (i = 0; i < excludeFeature.length; i += 1) { for (i = 0; i < excludeFeature.length; i += 1) {
nextArray.AddItem(_.text.FromString(excludeFeature[i])); nextArray.AddItem(_.text.FromString(excludeFeature[i]));
} }
result.SetItem(P("excludeFeature"), nextArray); result.SetItem(P("excludeFeature"), nextArray);
nextArray = _.collections.EmptyDynamicArray(); _.memory.Free(nextArray);
nextArray = _.collections.EmptyArrayList();
for (i = 0; i < includeMutator.length; i += 1) { for (i = 0; i < includeMutator.length; i += 1) {
nextArray.AddItem(_.text.FromString(includeFeature[i])); nextArray.AddItem(_.text.FromString(includeFeature[i]));
} }
result.SetItem(P("includeMutator"), nextArray); result.SetItem(P("includeMutator"), nextArray);
nextArray = _.collections.EmptyDynamicArray(); _.memory.Free(nextArray);
nextArray = _.collections.EmptyArrayList();
for (i = 0; i < includeFeatureAs.length; i += 1) for (i = 0; i < includeFeatureAs.length; i += 1)
{ {
nextPair = _.collections.EmptyAssociativeArray(); nextPair = _.collections.EmptyHashTable();
nextPair.SetItem(P("feature"), nextPair.SetString(P("feature"), includeFeatureAs[i].feature);
_.text.FromString(includeFeatureAs[i].feature)); nextPair.SetString(P("config"), includeFeatureAs[i].config);
nextPair.SetItem(P("config"),
_.text.FromString(includeFeatureAs[i].config));
nextArray.AddItem(nextPair); nextArray.AddItem(nextPair);
_.memory.Free(nextPair);
} }
result.SetItem(P("includeFeatureAs"), nextArray); result.SetItem(P("includeFeatureAs"), nextArray);
_.memory.Free(nextArray);
return result; return result;
} }
protected function FromData(AssociativeArray source) protected function FromData(HashTable source)
{ {
local int i; local int i;
local Text nextText; local ArrayList nextArray;
local DynamicArray includeFeatureAsSource; local HashTable nextPair;
if (source == none) { if (source == none) {
return; return;
} }
nextText = source.GetText(P("title")); title = source.GetFormattedString(P("title"));
if (nextText != none) { title = source.GetString(P("title"));
title = nextText.ToFormattedString(); nextArray = source.GetArrayList(P("includeFeature"));
} includeFeature = DynamicIntoStringArray(nextArray);
nextText = source.GetText(P("difficulty")); _.memory.Free(nextArray);
if (nextText != none) { nextArray = source.GetArrayList(P("excludeFeature"));
difficulty = nextText.ToString(); excludeFeature = DynamicIntoStringArray(nextArray);
} _.memory.Free(nextArray);
includeFeature = nextArray = source.GetArrayList(P("includeMutator"));
DynamicIntoStringArray(source.GetDynamicArray(P("includeFeature"))); includeMutator = DynamicIntoStringArray(nextArray);
excludeFeature = _.memory.Free(nextArray);
DynamicIntoStringArray(source.GetDynamicArray(P("excludeFeature"))); nextArray = source.GetArrayList(P("includeFeatureAs"));
includeMutator = if (nextArray == none) {
DynamicIntoStringArray(source.GetDynamicArray(P("includeMutator")));
includeFeatureAsSource = source.GetDynamicArray(P("includeFeatureAs"));
if (includeFeatureAsSource == none) {
return; return;
} }
includeFeatureAs.length = 0; includeFeatureAs.length = 0;
for (i = 0; i < includeFeatureAsSource.GetLength(); i += 1) for (i = 0; i < nextArray.GetLength(); i += 1)
{ {
includeFeatureAs[i] = AssociativeArrayIntoPair( nextPair = nextArray.GetHashTable(i);
includeFeatureAsSource.GetAssociativeArray(i)); includeFeatureAs[i] = HashTableIntoPair(nextPair);
_.memory.Free(nextPair);
} }
_.memory.Free(nextArray);
} }
private final function FeatureConfigPair AssociativeArrayIntoPair( private final function FeatureConfigPair HashTableIntoPair(HashTable source)
AssociativeArray source)
{ {
local Text nextText; local Text nextText;
local FeatureConfigPair result; local FeatureConfigPair result;
@ -145,7 +147,7 @@ private final function FeatureConfigPair AssociativeArrayIntoPair(
return result; return result;
} }
private final function array<string> DynamicIntoStringArray(DynamicArray source) private final function array<string> DynamicIntoStringArray(ArrayList source)
{ {
local int i; local int i;
local Text nextText; local Text nextText;

68
sources/GameModes/GameMode.uc

@ -54,72 +54,62 @@ protected function DefaultIt()
option.length = 0; option.length = 0;
} }
protected function AssociativeArray ToData() protected function HashTable ToData()
{ {
local int i; local int i;
local AssociativeArray result; local ArrayList nextArray;
local AssociativeArray nextPair; local HashTable result, nextPair;
local DynamicArray nextArray;
result = super.ToData(); result = super.ToData();
if (result == none) { if (result == none) {
return none; return none;
} }
result.SetItem(P("gameTypeClass"), _.text.FromString(gameTypeClass)); result.SetString(P("gameTypeClass"), gameTypeClass);
result.SetItem(P("acronym"), _.text.FromString(acronym)); result.SetString(P("acronym"), acronym);
result.SetItem(P("mapPrefix"), _.text.FromString(mapPrefix)); result.SetString(P("mapPrefix"), mapPrefix);
nextArray = _.collections.EmptyDynamicArray(); nextArray = _.collections.EmptyArrayList();
for (i = 0; i < option.length; i += 1) for (i = 0; i < option.length; i += 1)
{ {
nextPair = _.collections.EmptyAssociativeArray(); nextPair = _.collections.EmptyHashTable();
nextPair.SetItem(P("key"), _.text.FromString(option[i].key)); nextPair.SetString(P("key"), option[i].key);
nextPair.SetItem(P("value"), _.text.FromString(option[i].value)); nextPair.SetString(P("value"), option[i].value);
nextArray.AddItem(nextPair); nextArray.AddItem(nextPair);
_.memory.Free(nextPair);
} }
result.SetItem(P("option"), nextArray); result.SetItem(P("option"), nextArray);
_.memory.Free(nextArray);
return result; return result;
} }
protected function FromData(AssociativeArray source) protected function FromData(HashTable source)
{ {
local int i; local int i;
local Text nextText; local GameOption nextGameOption;
local GameOption nextPair; local ArrayList nextArray;
local DynamicArray nextArray; local HashTable nextPair;
super.FromData(source); super.FromData(source);
if (source == none) { if (source == none) {
return; return;
} }
nextText = source.GetText(P("gameTypeClass")); gameTypeClass = source.GetString(P("gameTypeClass"));
if (nextText != none) { acronym = source.GetString(P("acronym"));
gameTypeClass = nextText.ToString(); mapPrefix = source.GetString(P("mapPrefix"));
} nextArray = source.GetArrayList(P("option"));
nextText = source.GetText(P("acronym"));
if (nextText != none) {
acronym = nextText.ToString();
}
nextText = source.GetText(P("mapPrefix"));
if (nextText != none) {
mapPrefix = nextText.ToString();
}
nextArray = source.GetDynamicArray(P("option"));
if (nextArray == none) { if (nextArray == none) {
return; return;
} }
option.length = 0; option.length = 0;
for (i = 0; i < nextArray.GetLength(); i += 1) for (i = 0; i < nextArray.GetLength(); i += 1)
{ {
nextPair.key = ""; nextPair = HashTable(nextArray.GetItem(i));
nextPair.value = ""; if (nextPair == none) {
nextText = source.GetText(P("key")); continue;
if (nextText != none) {
nextPair.key = nextText.ToString();
}
nextText = source.GetText(P("value"));
if (nextText != none) {
nextPair.value = nextText.ToString();
} }
option[option.length] = nextPair; nextGameOption.key = nextPair.GetString(P("key"));
nextGameOption.value = nextPair.GetString(P("value"));
option[option.length] = nextGameOption;
_.memory.Free(nextPair);
} }
_.memory.Free(nextArray);
} }
public function Text GetGameTypeClass() public function Text GetGameTypeClass()

Loading…
Cancel
Save