mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
Minor changes to Profile loading for Auto Processes.
Minor changes to Branch Auto Update process.
This commit is contained in:
parent
f3a5f8e436
commit
43d192ec05
3 changed files with 55 additions and 53 deletions
|
|
@ -2494,9 +2494,7 @@ namespace ServerManagerTool.Lib
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var profile = ServerProfile.LoadFrom(profileFile);
|
var profile = ServerProfile.LoadFromProfileFileBasic(profileFile, null);
|
||||||
profile.DestroyServerFilesWatcher();
|
|
||||||
profile.SaveLauncher();
|
|
||||||
profiles.Add(ServerProfileSnapshot.Create(profile), profile);
|
profiles.Add(ServerProfileSnapshot.Create(profile), profile);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -3064,7 +3062,8 @@ namespace ServerManagerTool.Lib
|
||||||
ServerProcess = ServerProcess,
|
ServerProcess = ServerProcess,
|
||||||
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
||||||
};
|
};
|
||||||
profileExitCodes.TryAdd(profile, app.PerformProfileUpdate(branch, profile));
|
app.PerformProfileUpdate(branch, profile);
|
||||||
|
profileExitCodes.TryAdd(profile, app.ExitCode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -3084,7 +3083,8 @@ namespace ServerManagerTool.Lib
|
||||||
ServerProcess = ServerProcess,
|
ServerProcess = ServerProcess,
|
||||||
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
SteamCMDProcessWindowStyle = ProcessWindowStyle.Hidden
|
||||||
};
|
};
|
||||||
profileExitCodes.TryAdd(profile, app.PerformProfileUpdate(branch, profile));
|
app.PerformProfileUpdate(branch, profile);
|
||||||
|
profileExitCodes.TryAdd(profile, app.ExitCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3149,9 +3149,10 @@ namespace ServerManagerTool.Lib
|
||||||
// load all the profiles, do this at the very start in case the user changes one or more while the process is running.
|
// load all the profiles, do this at the very start in case the user changes one or more while the process is running.
|
||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
|
|
||||||
|
var profiles = _profiles.Keys.Where(p => p.EnableAutoBackup);
|
||||||
var exitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
|
var exitCodes = new ConcurrentDictionary<ServerProfileSnapshot, int>();
|
||||||
|
|
||||||
Parallel.ForEach(_profiles.Keys.Where(p => p.EnableAutoBackup), profile => {
|
Parallel.ForEach(profiles, profile => {
|
||||||
var app = new ServerApp
|
var app = new ServerApp
|
||||||
{
|
{
|
||||||
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
|
DeleteOldBackupFiles = Config.Default.AutoBackup_DeleteOldFiles,
|
||||||
|
|
@ -3160,7 +3161,8 @@ namespace ServerManagerTool.Lib
|
||||||
SendEmails = true,
|
SendEmails = true,
|
||||||
ServerProcess = ServerProcessType.AutoBackup
|
ServerProcess = ServerProcessType.AutoBackup
|
||||||
};
|
};
|
||||||
exitCodes.TryAdd(profile, app.PerformProfileBackup(profile, CancellationToken.None));
|
app.PerformProfileBackup(profile, CancellationToken.None);
|
||||||
|
exitCodes.TryAdd(profile, app.ExitCode);
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var profile in _profiles.Keys)
|
foreach (var profile in _profiles.Keys)
|
||||||
|
|
|
||||||
|
|
@ -4007,9 +4007,13 @@ namespace ServerManagerTool.Lib
|
||||||
if (profile.PlayerLevels.Count == 0)
|
if (profile.PlayerLevels.Count == 0)
|
||||||
{
|
{
|
||||||
profile.ResetLevelProgressionToOfficial(LevelProgression.Player);
|
profile.ResetLevelProgressionToOfficial(LevelProgression.Player);
|
||||||
profile.ResetLevelProgressionToOfficial(LevelProgression.Dino);
|
|
||||||
profile.EnableLevelProgressions = false;
|
profile.EnableLevelProgressions = false;
|
||||||
}
|
}
|
||||||
|
if (profile.DinoLevels.Count == 0)
|
||||||
|
{
|
||||||
|
profile.ResetLevelProgressionToOfficial(LevelProgression.Dino);
|
||||||
|
profile.EnableDinoLevelProgressions = false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Since these are not inserted the normal way, we force a recomputation here.
|
// Since these are not inserted the normal way, we force a recomputation here.
|
||||||
|
|
@ -4065,42 +4069,11 @@ namespace ServerManagerTool.Lib
|
||||||
|
|
||||||
public static ServerProfile LoadFromProfileFile(string file, ServerProfile profile)
|
public static ServerProfile LoadFromProfileFile(string file, ServerProfile profile)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
|
profile = LoadFromProfileFileBasic(file, profile);
|
||||||
|
|
||||||
|
if (profile is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (Path.GetExtension(file) != Config.Default.ProfileExtension)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
profile = profile ?? new ServerProfile();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var settings = new JsonSerializerSettings();
|
|
||||||
settings.Converters.Add(new NullableValueConverter<int>());
|
|
||||||
settings.Converters.Add(new NullableValueConverter<float>());
|
|
||||||
|
|
||||||
profile = JsonUtils.DeserializeFromFile<ServerProfile>(file, settings);
|
|
||||||
if (profile == null)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// could not load the profile file, just exit
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if profile id and filename match
|
|
||||||
var fileName = Path.GetFileNameWithoutExtension(file);
|
|
||||||
if (Guid.TryParse(fileName, out Guid fileId) && Guid.TryParse(profile.ProfileID, out Guid profileId))
|
|
||||||
{
|
|
||||||
// filename is a guid - check it against the profile id
|
|
||||||
if (!Guid.Equals(fileId, profileId))
|
|
||||||
{
|
|
||||||
// id values are not in sync, change the profile id to be the same as the filename
|
|
||||||
profile.ProfileID = fileId.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
profile.CheckLauncherArgs();
|
profile.CheckLauncherArgs();
|
||||||
|
|
||||||
if (profile.PGM_Enabled)
|
if (profile.PGM_Enabled)
|
||||||
|
|
@ -4109,20 +4082,12 @@ namespace ServerManagerTool.Lib
|
||||||
if (profile.SOTF_Enabled)
|
if (profile.SOTF_Enabled)
|
||||||
Config.Default.SectionSOTFEnabled = true;
|
Config.Default.SectionSOTFEnabled = true;
|
||||||
|
|
||||||
var configIniPath = Path.Combine(GetProfileServerConfigDir(profile), Config.Default.ServerGameUserSettingsConfigFile);
|
|
||||||
if (File.Exists(configIniPath))
|
|
||||||
{
|
|
||||||
profile = LoadFromINIFiles(configIniPath, profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profile.PlayerLevels.Count == 0)
|
if (profile.PlayerLevels.Count == 0)
|
||||||
{
|
{
|
||||||
profile.ResetLevelProgressionToOfficial(LevelProgression.Player);
|
profile.ResetLevelProgressionToOfficial(LevelProgression.Player);
|
||||||
profile.ResetLevelProgressionToOfficial(LevelProgression.Dino);
|
|
||||||
profile.EnableLevelProgressions = false;
|
profile.EnableLevelProgressions = false;
|
||||||
profile.EnableDinoLevelProgressions = false;
|
|
||||||
}
|
}
|
||||||
else if (profile.DinoLevels.Count == 0)
|
if (profile.DinoLevels.Count == 0)
|
||||||
{
|
{
|
||||||
profile.ResetLevelProgressionToOfficial(LevelProgression.Dino);
|
profile.ResetLevelProgressionToOfficial(LevelProgression.Dino);
|
||||||
profile.EnableDinoLevelProgressions = false;
|
profile.EnableDinoLevelProgressions = false;
|
||||||
|
|
@ -4151,6 +4116,43 @@ namespace ServerManagerTool.Lib
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ServerProfile LoadFromProfileFileBasic(string file, ServerProfile profile)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(file) || !File.Exists(file))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (Path.GetExtension(file) != Config.Default.ProfileExtension)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (profile is null)
|
||||||
|
profile = new ServerProfile();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var settings = new JsonSerializerSettings();
|
||||||
|
settings.Converters.Add(new NullableValueConverter<int>());
|
||||||
|
settings.Converters.Add(new NullableValueConverter<float>());
|
||||||
|
|
||||||
|
profile = JsonUtils.DeserializeFromFile<ServerProfile>(file, settings);
|
||||||
|
if (profile == null)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// could not load the profile file, just exit
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var configIniPath = Path.Combine(GetProfileServerConfigDir(profile), Config.Default.ServerGameUserSettingsConfigFile);
|
||||||
|
if (File.Exists(configIniPath))
|
||||||
|
{
|
||||||
|
profile = LoadFromINIFiles(configIniPath, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
profile._lastSaveLocation = file;
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
public void Save(bool updateFolderPermissions, bool updateSchedules, ProgressDelegate progressCallback)
|
public void Save(bool updateFolderPermissions, bool updateSchedules, ProgressDelegate progressCallback)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(Config.Default.DataDir))
|
if (string.IsNullOrWhiteSpace(Config.Default.DataDir))
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ namespace ServerManagerTool.Lib
|
||||||
public string PGM_Name;
|
public string PGM_Name;
|
||||||
public string AdminPassword;
|
public string AdminPassword;
|
||||||
public string ServerName;
|
public string ServerName;
|
||||||
public string ServerArgs;
|
|
||||||
public IPAddress ServerIPAddress;
|
public IPAddress ServerIPAddress;
|
||||||
public int ServerPort;
|
public int ServerPort;
|
||||||
public int ServerPeerPort;
|
public int ServerPeerPort;
|
||||||
|
|
@ -70,7 +69,6 @@ namespace ServerManagerTool.Lib
|
||||||
PGM_Name = profile.PGM_Name,
|
PGM_Name = profile.PGM_Name,
|
||||||
AdminPassword = profile.AdminPassword,
|
AdminPassword = profile.AdminPassword,
|
||||||
ServerName = profile.ServerName,
|
ServerName = profile.ServerName,
|
||||||
ServerArgs = profile.GetServerArgs(),
|
|
||||||
ServerIPAddress = string.IsNullOrWhiteSpace(profile.ServerIP) ? IPAddress.Loopback : IPAddress.TryParse(profile.ServerIP.Trim(), out IPAddress ipAddress) ? ipAddress : IPAddress.Loopback,
|
ServerIPAddress = string.IsNullOrWhiteSpace(profile.ServerIP) ? IPAddress.Loopback : IPAddress.TryParse(profile.ServerIP.Trim(), out IPAddress ipAddress) ? ipAddress : IPAddress.Loopback,
|
||||||
ServerPort = profile.ServerPort,
|
ServerPort = profile.ServerPort,
|
||||||
ServerPeerPort = profile.ServerPeerPort,
|
ServerPeerPort = profile.ServerPeerPort,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue