7 protected const string DEFAULT_FILE_NAME =
"GeneratedServerConfig";
10 protected ref array<ref SCR_WidgetListEntry> m_aDSConfigEntries = {};
20 game =
new DSGameConfig();
27 void StoreFullJson(array<ref SCR_WidgetListEntry> entries, array<ref DSMod> modList, WorkshopItem scenarioMod)
29 m_aDSConfigEntries = entries;
32 bindAddress = FindValue(
"bindAddress");
33 bindPort = StringToNumber(FindValue(
"bindPort"));
34 publicAddress = FindValue(
"publicAddress");
35 publicPort = StringToNumber(FindValue(
"publicPort"));
38 game.name = FindValue(
"name");
39 game.maxPlayers = StringToNumber(FindValue(
"maxPlayers"));
40 game.password = FindValue(
"password");
41 game.passwordAdmin = FindValue(
"passwordAdmin");
48 if (gamePropertiesSCr)
53 gamePropertiesSCr.VONDisableDirectSpeechUI =
SCR_JsonApiStructHandler.StringToBool(FindValue(
"VONDisableDirectSpeechUI"));
54 gamePropertiesSCr.VONCanTransmitCrossFaction =
SCR_JsonApiStructHandler.StringToBool(FindValue(
"VONCanTransmitCrossFaction"));
55 gamePropertiesSCr.serverMaxViewDistance = StringToNumber(FindValue(
"serverMaxViewDistance"));
56 gamePropertiesSCr.networkViewDistance = StringToNumber(FindValue(
"networkViewDistance"));
57 gamePropertiesSCr.serverMinGrassDistance = StringToNumber(FindValue(
"serverMinGrassDistance"));
61 game.scenarioId = FindValue(
"scenarioId");
72 game.hostedScenarioModId = scenarioMod.Id();
77 for (
int i = 0, count = game.mods.Count(); i < count; i++)
79 if (game.mods[i].modId == scenarioMod.Id())
89 DSMod scenarioDSMod =
new DSMod();
90 scenarioDSMod.modId = scenarioMod.Id();
91 scenarioDSMod.name = scenarioMod.Name();
92 scenarioDSMod.version = scenarioMod.GetActiveRevision().GetVersion();
95 game.mods.Insert(scenarioDSMod);
101 string GetConfigName()
103 string name = FindValue(
"fileName");
107 name = FindValue(
"name");
111 return DEFAULT_FILE_NAME;
120 protected string FindValue(
string propertyName,
string groupTag =
"")
122 string nameTrimmed =
"";
124 for (
int i = 0, count = m_aDSConfigEntries.Count(); i < count; i++)
126 nameTrimmed = m_aDSConfigEntries[i].GetPropertyName();
127 nameTrimmed = nameTrimmed.Trim();
132 if (nameTrimmed == propertyName)
133 return m_aDSConfigEntries[i].ValueAsString();
138 if (nameTrimmed == propertyName && m_aDSConfigEntries[i].GetGroupTag() == groupTag)
139 return m_aDSConfigEntries[i].ValueAsString();
147 protected float StringToNumber(
string str)
152 return str.ToFloat();
170 RegV(
"serverMaxViewDistance");
171 RegV(
"networkViewDistance");
172 RegV(
"serverMinGrassDistance");
180 UnregV(
"disableThirdPerson");
182 UnregV(
"VONDisableUI");
184 UnregV(
"VONDisableDirectSpeechUI");
186 UnregV(
"VONCanTransmitCrossFaction");
193 RegV(
"disableThirdPerson");
194 RegV(
"VONDisableUI");
195 RegV(
"VONDisableDirectSpeechUI");
196 RegV(
"VONCanTransmitCrossFaction");