Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add crossplay support #1

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ServerDetailsWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Window x:Class="ValheimServerWarden.ServerDetailsWindow"
<Window x:Class="ValheimServerWarden.ServerDetailsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down Expand Up @@ -251,6 +251,7 @@
</TextBox.ContextMenu>
</TextBox>
<CheckBox x:Name="chkPublic" Content="Public" Margin="5,5,0,5" VerticalAlignment="Top" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" ToolTip="Whether server is listed in the in-game community server list"/>
<CheckBox x:Name="chkCrossplay" Content="Crossplay" Margin="5,5,0,5" VerticalAlignment="Top" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" ToolTip="Whether cross-play is enabled between different platforms"/>
</Grid>
</Border>
<Label Content="Management Settings" Grid.Row="2" Margin="10,5,0,0"/>
Expand Down
4 changes: 3 additions & 1 deletion ServerDetailsWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
Expand Down Expand Up @@ -257,6 +257,7 @@ private void ServerToControls()
txtPassword.Text = Server.Password;
txtSaveDir.Text = Server.SaveDir;
chkPublic.IsChecked = Server.Public;
chkCrossplay.IsChecked = Server.Crossplay;
if (Server.InstallPath != null)
{
txtServerDir.Text = Server.InstallPath;
Expand Down Expand Up @@ -427,6 +428,7 @@ private void btnSave_Click(object sender, RoutedEventArgs e)
Server.Password = txtPassword.Text;
Server.SaveDir = txtSaveDir.Text;
Server.Public = chkPublic.IsChecked.GetValueOrDefault();
Server.Crossplay = chkCrossplay.IsChecked.GetValueOrDefault();
Server.InstallPath = txtServerDir.Text;
Server.InstallMethod = (ValheimServer.ServerInstallMethod)cmbServerType.SelectedIndex;

Expand Down
25 changes: 21 additions & 4 deletions ValheimServer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
Expand Down Expand Up @@ -69,6 +69,7 @@ struct ServerData
internal string password;
internal string savedir;
internal bool pub;
internal bool crossplay;
internal bool autostart;
internal bool rawlog;
internal int restartHours;
Expand Down Expand Up @@ -207,6 +208,17 @@ public bool Public
this.data.pub = value;
}
}
public bool Crossplay
{
get
{
return this.data.crossplay;
}
set
{
this.data.crossplay = value;
}
}
public bool Autostart
{
get
Expand Down Expand Up @@ -468,14 +480,15 @@ static ValheimServer()
}
}).Start();
}
public ValheimServer(string name, int port, string world, string password, bool pubserver, bool autostart, bool rawlog, int restarthours, bool updateonrestart, int updatecheckminutes, string discordwebhook, Dictionary<string,string> discordmessages, Dictionary<string, string> discordservereventnames, ServerInstallMethod install, string instpath, ProcessPriorityClass processpriority, bool umodupdating)
public ValheimServer(string name, int port, string world, string password, bool pubserver, bool crossplay, bool autostart, bool rawlog, int restarthours, bool updateonrestart, int updatecheckminutes, string discordwebhook, Dictionary<string,string> discordmessages, Dictionary<string, string> discordservereventnames, ServerInstallMethod install, string instpath, ProcessPriorityClass processpriority, bool umodupdating)
{
this.data.name = name;
this.data.port = 2456;
this.data.world = world;
this.data.password = password;
this.data.savedir = "";
this.data.pub = pubserver;
this.data.crossplay = crossplay;
this.data.autostart = autostart;
this.data.rawlog = rawlog;
this.data.restartHours = restarthours;
Expand Down Expand Up @@ -558,11 +571,11 @@ private void RestartTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs
}
}

public ValheimServer() : this("My Server", 2456, "Dedicated", "Secret", false, false, false, 0, false, 0, null, new Dictionary<string, string>(), new Dictionary<string, string>(), ServerInstallMethod.Manual, Properties.Settings.Default.ServerFilePath, ProcessPriorityClass.Normal, false)
public ValheimServer() : this("My Server", 2456, "Dedicated", "Secret", false, false, false, false, 0, false, 0, null, new Dictionary<string, string>(), new Dictionary<string, string>(), ServerInstallMethod.Manual, Properties.Settings.Default.ServerFilePath, ProcessPriorityClass.Normal, false)
{
}

public ValheimServer(string name) : this(name, 2456, "Dedicated", "Secret", false, false, false, 0, false, 0, null, new Dictionary<string,string>(), new Dictionary<string, string>(), ServerInstallMethod.Manual, Properties.Settings.Default.ServerFilePath, ProcessPriorityClass.Normal, false)
public ValheimServer(string name) : this(name, 2456, "Dedicated", "Secret", false, false, false, false, 0, false, 0, null, new Dictionary<string,string>(), new Dictionary<string, string>(), ServerInstallMethod.Manual, Properties.Settings.Default.ServerFilePath, ProcessPriorityClass.Normal, false)
{

}
Expand Down Expand Up @@ -936,6 +949,10 @@ private void StartServer()
return;
}
string arguments = $"-nographics -batchmode -name \"{this.Name}\" -port {this.Port} -world \"{this.World}\" -public {Convert.ToInt32(Public)}";
if (this.Crossplay)
{
arguments += " -crossplay";
}
if (Password != null & Password.Length > 0)
{
arguments += $" -password \"{this.Password}\"";
Expand Down