Skip to content

Commit 8c90880

Browse files
committed
Refactor AdvancedOptions to use correct type
Changed AdvancedOptions from ServerCfg to AdvancedOptions type in ServerProfile. Updated related property assignments and command line generation to use the new advanced options file. This improves type safety and ensures advanced options are handled separately from server configuration.
1 parent 8982499 commit 8c90880

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

FASTER/Models/ServerProfile.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal static void AddServerProfile(string profileName)
2525
var currentProfiles = Properties.Settings.Default.Profiles;
2626
var p = new ServerProfile(profileName);
2727
p.ServerCfg.ServerCfgContent = p.ServerCfg.ProcessFile();
28-
p.ServerCfg.AdvancedOptionsContent = p.AdvancedOptions.ProcessFile();
28+
p.AdvancedOptions.AdvancedOptionsContent = p.AdvancedOptions.ProcessFile();
2929
p.BasicCfg.BasicContent = p.BasicCfg.ProcessFile();
3030
p.ArmaProfile.ArmaProfileContent = p.ArmaProfile.ProcessFile();
3131
currentProfiles.Add(p);
@@ -73,7 +73,7 @@ public class ServerProfile : INotifyPropertyChanged
7373
private bool _profileModsFilterIsRegex = false;
7474
private bool _profileModsFilterIsInvalid = false;
7575
private ServerCfg _serverCfg;
76-
private ServerCfg _advancedOptions;
76+
private AdvancedOptions _advancedOptions;
7777
private Arma3Profile _armaProfile;
7878
private BasicCfg _basicCfg;
7979

@@ -393,7 +393,7 @@ public ServerCfg ServerCfg
393393
}
394394
}
395395

396-
public ServerCfg AdvancedOptions
396+
public AdvancedOptions AdvancedOptions
397397
{
398398
get => _advancedOptions;
399399
set
@@ -443,7 +443,7 @@ public ServerProfile(string name, bool createFolder = true)
443443
ArmaProfile = new Arma3Profile();
444444
BasicCfg = new BasicCfg();
445445
ServerCfg.ServerCfgContent = ServerCfg.ProcessFile();
446-
ServerCfg.AdvancedOptionsContent = AdvancedOptions.ProcessFile();
446+
AdvancedOptions.AdvancedOptionsContent = AdvancedOptions.ProcessFile();
447447
ArmaProfile.ArmaProfileContent = ArmaProfile.ProcessFile();
448448
BasicCfg.BasicContent = BasicCfg.ProcessFile();
449449
if (createFolder)
@@ -454,11 +454,12 @@ public ServerProfile()
454454
{
455455
_id = $"_{Guid.NewGuid():N}";
456456
Name = _id;
457-
ServerCfg = new ServerCfg(){ Hostname = Name};
458-
ArmaProfile = new Arma3Profile();
459-
BasicCfg = new BasicCfg();
457+
ServerCfg = new ServerCfg(){ Hostname = Name};
458+
ArmaProfile = new Arma3Profile();
459+
BasicCfg = new BasicCfg();
460+
AdvancedOptions = new AdvancedOptions();
460461
ServerCfg.ServerCfgContent = ServerCfg.ProcessFile();
461-
ServerCfg.AdvancedOptionsContent = AdvancedOptions.ProcessFile();
462+
AdvancedOptions.AdvancedOptionsContent = AdvancedOptions.ProcessFile();
462463
ArmaProfile.ArmaProfileContent = ArmaProfile.ProcessFile();
463464
BasicCfg.BasicContent = BasicCfg.ProcessFile();
464465
}
@@ -543,15 +544,17 @@ private string GetCommandLine()
543544
{
544545

545546

546-
string config = Path.Combine(ArmaPath, "Servers", Id, "server_config.cfg");
547-
string basic = Path.Combine(ArmaPath, "Servers", Id, "server_basic.cfg");
547+
string config = Path.Combine(ArmaPath, "Servers", Id, "server_config.cfg");
548+
string advanced = Path.Combine(ArmaPath, "Servers", Id, "server_advanced.cfg");
549+
string basic = Path.Combine(ArmaPath, "Servers", Id, "server_basic.cfg");
548550

549551
string playerMods = string.Join(";", ProfileMods.Where(m => m.ClientSideChecked).OrderBy(m => m.LoadPriority).Select(m => $"@{Functions.SafeName(m.Name)}"));
550552
string serverMods = string.Join(";", ProfileMods.Where(m => m.ServerSideChecked).OrderBy(m => m.LoadPriority).Select(m => $"@{Functions.SafeName(m.Name)}"));
551553
List<string> arguments = new List<string>
552554
{
553555
$"-port={Port}",
554556
$" \"-config={config}\"",
557+
$" \"-advanced={advanced}\"",
555558
$" \"-cfg={basic}\"",
556559
$" \"-profiles={Path.Combine(ArmaPath, "Servers", Id)}\"",
557560
$" -name={Id}",
@@ -695,4 +698,4 @@ public override string ToString()
695698
private void RaisePropertyChanged(string property)
696699
{ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); }
697700
}
698-
}
701+
}

0 commit comments

Comments
 (0)