From c13220ac0d57a7dc117e3a5299a9baa04b9ec278 Mon Sep 17 00:00:00 2001 From: N0tiC Date: Sun, 16 Oct 2022 03:47:07 +0200 Subject: [PATCH] Updated StartServerScript with updated arguments and warnings. Fixed some warnings/messages in IDE. --- SteamServerCreationTool/Data/Settings.cs | 18 +++++++++--------- .../Forms/CreateServerForm.Designer.cs | 4 ++-- .../Forms/CreateServerForm.cs | 11 +++++++---- .../Forms/ManageInstallsForm.cs | 1 + SteamServerCreationTool/Forms/SettingsForm.cs | 2 +- .../Resources/StartServerScript.txt | 7 ++++--- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/SteamServerCreationTool/Data/Settings.cs b/SteamServerCreationTool/Data/Settings.cs index 7309188..32073e7 100644 --- a/SteamServerCreationTool/Data/Settings.cs +++ b/SteamServerCreationTool/Data/Settings.cs @@ -26,7 +26,7 @@ public class Settings public string GetLogin() { if (!useUserData) return "anonymous"; - else if (useUserData && !userData.IsEmpty()) return userData.username + " " + userData.GetPassword(); + else if (useUserData && !userData.IsEmpty()) return userData.Username + " " + userData.GetPassword(); else return null; } } @@ -52,30 +52,30 @@ public InstalledServer(string name, string installPath, App app) [Serializable] public class UserData { - public string username { get; private set; } - public string password { get; private set; } + public string Username { get; private set; } + public string Password { get; private set; } public UserData() { - this.username = null; - this.password = null; + this.Username = null; + this.Password = null; } public bool IsEmpty() { - if (string.IsNullOrWhiteSpace(this.username) || this.password == null || this.password.Length < 1) return true; + if (string.IsNullOrWhiteSpace(this.Username) || this.Password == null || this.Password.Length < 1) return true; else return false; } - public void SetUsername(string name) => this.username = name; + public void SetUsername(string name) => this.Username = name; - public void SetPassword(string pass) => this.password = Core.Base64Encode(pass); + public void SetPassword(string pass) => this.Password = Core.Base64Encode(pass); public string GetPassword() { try { - return Core.Base64Decode(this.password); + return Core.Base64Decode(this.Password); } catch { return null; } } diff --git a/SteamServerCreationTool/Forms/CreateServerForm.Designer.cs b/SteamServerCreationTool/Forms/CreateServerForm.Designer.cs index 0baa7ef..03264f3 100644 --- a/SteamServerCreationTool/Forms/CreateServerForm.Designer.cs +++ b/SteamServerCreationTool/Forms/CreateServerForm.Designer.cs @@ -138,7 +138,7 @@ private void InitializeComponent() this.linkLabel2.TabIndex = 19; this.linkLabel2.TabStop = true; this.linkLabel2.Text = "Server Setup"; - this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked); + this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel2_LinkClicked); // // label4 // @@ -162,7 +162,7 @@ private void InitializeComponent() this.linkLabel1.TabIndex = 18; this.linkLabel1.TabStop = true; this.linkLabel1.Text = "Gameserver Login Tokens (GSLTs)"; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabel1_LinkClicked); // // InstallDirButton // diff --git a/SteamServerCreationTool/Forms/CreateServerForm.cs b/SteamServerCreationTool/Forms/CreateServerForm.cs index 4063670..f5f1471 100644 --- a/SteamServerCreationTool/Forms/CreateServerForm.cs +++ b/SteamServerCreationTool/Forms/CreateServerForm.cs @@ -1,4 +1,6 @@ -using SteamServerCreationTool.Data; +#pragma warning disable IDE0044 + +using SteamServerCreationTool.Data; using System; using System.ComponentModel; using System.Diagnostics; @@ -31,7 +33,7 @@ private void CreateServerForm_Load(object sender, EventArgs e) } } - private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void LinkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (app != null) { @@ -41,7 +43,7 @@ private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs } } - private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) => Process.Start("https://steamcommunity.com/dev/managegameservers?l=english"); + private void LinkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) => Process.Start("https://steamcommunity.com/dev/managegameservers?l=english"); private void InstallDirButton_Click(object sender, EventArgs e) { @@ -107,7 +109,7 @@ private void CancelButton_Click(object sender, EventArgs e) Close(); } - private void StartSteamCMDServerDownload(Data.App app, bool skip = false) + private void StartSteamCMDServerDownload(Data.App app) { //Keep track of success bool install = true; @@ -169,6 +171,7 @@ private void StartSteamCMDServerDownload(Data.App app, bool skip = false) startScript = startScript.Replace("{server_dir}", installDir); startScript = startScript.Replace("{app_id}", appID); startScript = startScript.Replace("{app_name}", app.Name); + startScript = startScript.Replace("{login_cred}", main.settings.GetLogin()); Core.SaveToFile(installDir + @"\StartServerScript.bat", startScript); diff --git a/SteamServerCreationTool/Forms/ManageInstallsForm.cs b/SteamServerCreationTool/Forms/ManageInstallsForm.cs index e6e810e..0c0d022 100644 --- a/SteamServerCreationTool/Forms/ManageInstallsForm.cs +++ b/SteamServerCreationTool/Forms/ManageInstallsForm.cs @@ -504,6 +504,7 @@ private void GenerateScriptButton_Click(object sender, EventArgs e) startScript = startScript.Replace("{server_dir}", app.installPath); startScript = startScript.Replace("{app_id}", app.app.Appid.ToString()); startScript = startScript.Replace("{app_name}", app.app.Name); + startScript = startScript.Replace("{login_cred}", main.settings.GetLogin()); Core.SaveToFile(app.installPath + @"\StartServerScript.bat", startScript); } diff --git a/SteamServerCreationTool/Forms/SettingsForm.cs b/SteamServerCreationTool/Forms/SettingsForm.cs index c0a2c7a..4c7f7c6 100644 --- a/SteamServerCreationTool/Forms/SettingsForm.cs +++ b/SteamServerCreationTool/Forms/SettingsForm.cs @@ -15,7 +15,7 @@ public SettingsForm(MainForm main) private void CreateServerForm_Load(object sender, EventArgs e) { - username_inputbox.Text = main.settings.userData.username; + username_inputbox.Text = main.settings.userData.Username; string pass = main.settings.userData.GetPassword(); if (pass != null) password_inputbox.Text = pass; diff --git a/SteamServerCreationTool/Resources/StartServerScript.txt b/SteamServerCreationTool/Resources/StartServerScript.txt index b82f45f..02e9954 100644 --- a/SteamServerCreationTool/Resources/StartServerScript.txt +++ b/SteamServerCreationTool/Resources/StartServerScript.txt @@ -6,6 +6,8 @@ :: :: You will need to edit the 3 lines below with valid information :: Row: 19, 20, 21 (Bellow the lines beginning with "::") +:: +:: !DO NOT ADD SPACES UNLESS THERE ARE SPACES IN THE ARGUMENT OR DIRECTORY PATH! :: :: Examples: :: SET serverExecutablePath=D:\Valheim Server @@ -59,15 +61,14 @@ SET serverLaunchOptions=-Some -Launch Options :: DO NOT EDIT BELOW THIS LINE; UNLESS YOU KNOW WHAT YOU ARE DOING ::================================================================ - SET pathExist=%serverExecutablePath%\%serverExecutableFileName% PUSHD {steamcmd_dir} -START /wait steamcmd +force_install_dir "{server_dir}" +login anonymous +app_update {app_id} validated +quit +START /wait steamcmd +force_install_dir "{server_dir}" +login "{login_cred}" +app_update {app_id} validated +quit PUSHD {server_dir} ECHO Protecting {app_name} from crashes... ECHO To exit {app_name}, close this window first. It will restart otherwise. -TITLE {app_name} +TITLE "{app_name}" IF EXIST "%pathExist%" GOTO server CLS