Skip to content

Commit

Permalink
Fixed favourites being inconsistent displaying servers properly. Some…
Browse files Browse the repository at this point in the history
… changes regarding how servers are displayed and fetched data from. Mirrored official list URI to internet list. Improved error handling and made error messages more verbose.
  • Loading branch information
BigETI committed Dec 13, 2018
1 parent e2d82fd commit 33e8e8f
Show file tree
Hide file tree
Showing 35 changed files with 3,737 additions and 3,533 deletions.
Binary file modified .vs/SAMPLauncherNET/v15/.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions SAMPLauncherNET/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.6.2")]
[assembly: AssemblyFileVersion("1.0.6.2")]
[assembly: AssemblyVersion("1.0.6.3")]
[assembly: AssemblyFileVersion("1.0.6.3")]
3 changes: 2 additions & 1 deletion SAMPLauncherNET/SAMPLauncherNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
<Compile Include="Source\SAMPLauncherNET\Core\LauncherConfigDataContract.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\MediaState.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\OnFilterEventHandler.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\PingString.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\Player.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\PlayerCountString.cs" />
<Compile Include="Source\SAMPLauncherNET\Core\PluginDataContract.cs" />
Expand Down Expand Up @@ -412,7 +413,7 @@
<MergeAsm Include="$(OutputPath)ICSharpCode.SharpZipLib.dll" />
<MergeAsm Include="$(OutputPath)INIEngine.dll" />
<MergeAsm Include="$(OutputPath)MaterialSkin.dll" />
<MergeAsm Include="$(OutputPath)Ude.dll" />
<MergeAsm Include="$(OutputPath)Ude.dll" />
<MergeAsm Include="$(OutputPath)UpdaterNET.dll" />
<MergeAsm Include="$(OutputPath)WinFormsTranslator.dll" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ public class BackendRESTfulServer : Server
/// Constructor
/// </summary>
/// <param name="serverData">Server data</param>
public BackendRESTfulServer(BackendRESTfulServerDataContract serverData) : base(serverData.Host, true)
public BackendRESTfulServer(BackendRESTfulServerDataContract serverData) : base(serverData.Host, false)
{
requestsRequired.Lock(ERequestType.Information);
hostname = serverData.Hostname;
if (serverData.Hostname.Trim().Length > 0)
{
hostname = serverData.Hostname;
}
gamemode = serverData.Gamemode;
playerCount = serverData.PlayerCount;
maxPlayers = serverData.MaxPlayers;
hasPassword = serverData.HasPassword;
language = serverData.Language;
FetchDataAsync(ERequestType.Ping);
//FetchDataAsync(ERequestType.Ping);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,23 @@ public class BackendRESTfulServerDataContract
[DataMember(Name = "pa")]
private bool hasPassword = false;

/// <summary>
/// Version
/// </summary>
[DataMember(Name = "vn")]
private string version = "";

/// <summary>
/// Host
/// </summary>
public string Host
{
get
{
if (host == null)
{
host = "";
}
return host;
}
}
Expand All @@ -71,6 +81,10 @@ public string Hostname
{
get
{
if (hostname == null)
{
hostname = "";
}
return hostname;
}
}
Expand Down Expand Up @@ -104,6 +118,10 @@ public string Gamemode
{
get
{
if (gamemode == null)
{
gamemode = "";
}
return gamemode;
}
}
Expand All @@ -115,6 +133,10 @@ public string Language
{
get
{
if (language == null)
{
language = "";
}
return language;
}
}
Expand All @@ -129,5 +151,20 @@ public bool HasPassword
return hasPassword;
}
}

/// <summary>
/// Version
/// </summary>
public string Version
{
get
{
if (version == null)
{
version = "";
}
return version;
}
}
}
}
10 changes: 5 additions & 5 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/ChatlogFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static string Format(string text, EChatlogFormatType formatType, bool sho
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
}
string upper_match = match.Value.ToUpper();
Expand All @@ -102,7 +102,7 @@ public static string Format(string text, EChatlogFormatType formatType, bool sho
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
}
ret.Append(@"}\highlight2");
Expand Down Expand Up @@ -177,14 +177,14 @@ public static string Format(string text, EChatlogFormatType formatType, bool sho
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
}
}
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
if (formatType == EChatlogFormatType.HTML)
{
Expand All @@ -196,7 +196,7 @@ public static string Format(string text, EChatlogFormatType formatType, bool sho
catch (Exception e)
{
ret.Clear();
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
return ret.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public string Host
{
get
{
if (host == null)
{
host = "";
}
return host;
}
}
Expand All @@ -47,6 +51,10 @@ public string Hostname
{
get
{
if (hostname == null)
{
hostname = "";
}
return hostname;
}
}
Expand All @@ -58,6 +66,10 @@ public string Mode
{
get
{
if (mode == null)
{
mode = "";
}
return mode;
}
}
Expand Down
17 changes: 13 additions & 4 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/FavouriteServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ public string RCONPassword
/// <param name="rconPassword">RCON password</param>
public FavouriteServer(string ipAddressAndPortString, string cachedHostname, string cachedGamemode, string serverPassword, string rconPassword) : base(ipAddressAndPortString, false)
{
requestsRequired[ERequestType.Information] = false;
hostname = cachedHostname;
//requestsRequired[ERequestType.Information] = false;
if (cachedHostname != null)
{
if (cachedHostname.Trim().Length > 0)
{
hostname = cachedHostname;
}
}
gamemode = cachedGamemode;
this.serverPassword = serverPassword;
this.rconPassword = rconPassword;
Expand All @@ -65,8 +71,11 @@ public FavouriteServer(string ipAddressAndPortString, string cachedHostname, str
/// <param name="fdc">Favorite data contract</param>
public FavouriteServer(FavouriteDataContract fdc) : base(fdc.Host, false)
{
requestsRequired[ERequestType.Information] = false;
hostname = fdc.Hostname;
//requestsRequired[ERequestType.Information] = false;
if (fdc.Hostname.Trim().Length > 0)
{
hostname = fdc.Hostname;
}
serverPassword = "";
rconPassword = "";
FetchDataAsync(ERequestType.Ping);
Expand Down
2 changes: 1 addition & 1 deletion SAMPLauncherNET/Source/SAMPLauncherNET/Core/FileState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public FileState(string path)
catch (Exception e)
{
lastWriteDateTime = DateTime.Now;
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public GeoLocationData RequestData(string host)
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
return ret;
}
Expand Down
6 changes: 3 additions & 3 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/MediaState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void AddFilesState(string path)
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
}

Expand Down Expand Up @@ -105,7 +105,7 @@ private IEnumerable<string> GetFiles(string path)
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
return ret;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ public string[] GetModifiedAdded()
}
catch (Exception e)
{
Console.Error.WriteLine(e.Message);
Console.Error.WriteLine(e);
}
}
else
Expand Down
66 changes: 66 additions & 0 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/PingString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;

/// <summary>
/// SA:MP launcher .NET namespace
/// </summary>
namespace SAMPLauncherNET
{
/// <summary>
/// Ping string class
/// </summary>
public class PingString : IComparable, IComparable<PingString>
{
/// <summary>
/// Ping
/// </summary>
private readonly uint ping;

/// <summary>
/// Constructor
/// </summary>
/// <param name="ping">Ping</param>
public PingString(uint ping)
{
this.ping = ping;
}

/// <summary>
/// Compare to
/// </summary>
/// <param name="obj">Object</param>
/// <returns>Result</returns>
public int CompareTo(object obj)
{
int ret = 1;
if (obj != null)
{
ret = CompareTo(obj as PingString);
}
return ret;
}

/// <summary>
/// CompareTo
/// </summary>
/// <param name="other">Other</param>
/// <returns>Result</returns>
public int CompareTo(PingString other)
{
int ret = 1;
if (other != null)
{
ret = ping.CompareTo(other.ping);
}
return ret;
}

/// <summary>
/// To string
/// </summary>
/// <returns>String representation</returns>
public override string ToString()
{
return ((ping == uint.MaxValue) ? "-" : ping.ToString());
}
}
}
4 changes: 4 additions & 0 deletions SAMPLauncherNET/Source/SAMPLauncherNET/Core/PluginProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private static string GetDownloadURL(string infoPath, string githubAPIURL, ref G
}
catch (Exception e)
{
Console.Error.WriteLine(e);
MessageBox.Show(e.Message, Translator.GetTranslation("PLUGIN_ERROR_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Expand All @@ -70,6 +71,7 @@ private static string GetDownloadURL(string infoPath, string githubAPIURL, ref G
}
catch (Exception e)
{
Console.Error.WriteLine(e);
MessageBox.Show(e.Message, Translator.GetTranslation("PLUGIN_ERROR_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Expand Down Expand Up @@ -211,6 +213,7 @@ public static InstalledPlugin Update(PluginDataContract plugin)
}
catch (Exception e)
{
Console.Error.WriteLine(e);
MessageBox.Show(e.Message, Translator.GetTranslation("PLUGIN_ERROR_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Expand Down Expand Up @@ -244,6 +247,7 @@ public static InstalledPlugin Update(PluginDataContract plugin)
}
catch (Exception e)
{
Console.Error.WriteLine(e);
MessageBox.Show(e.Message, Translator.GetTranslation("PLUGIN_ERROR_TITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Expand Down
Loading

0 comments on commit 33e8e8f

Please sign in to comment.