Added checks and fixes

This commit is contained in:
Amazed 2019-02-12 15:42:42 +01:00
parent 3da514d0f4
commit 4f37f0a3b9
2 changed files with 19 additions and 0 deletions

View File

@ -51,6 +51,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include=".gitignore" />
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -36,6 +36,11 @@ namespace GiantsLauncher
string server_ok = ""; string server_ok = "";
foreach (string server in SERVERS) foreach (string server in SERVERS)
{ {
if (server.Length > 15)
{
Console.WriteLine("Server {0} has length > 15, skipping.", server);
continue;
}
Console.WriteLine("Testing {0}", server); Console.WriteLine("Testing {0}", server);
if (TestServer(server)) if (TestServer(server))
{ {
@ -53,7 +58,15 @@ namespace GiantsLauncher
Byte[] data = System.Text.Encoding.ASCII.GetBytes(server_ok); Byte[] data = System.Text.Encoding.ASCII.GetBytes(server_ok);
writer.Seek(offset, SeekOrigin.Begin); //move cursor to the position writer.Seek(offset, SeekOrigin.Begin); //move cursor to the position
writer.Write(data);//write it writer.Write(data);//write it
// add padding
for (int i = 0; i < 15 - data.Length; i++)
{
writer.Write((byte)0);//write it
}
} }
} else
{
Console.WriteLine("No working master server found... RIP.");
} }
Process.Start(GIANTS_PATH); Process.Start(GIANTS_PATH);
} }
@ -133,6 +146,11 @@ namespace GiantsLauncher
return false; return false;
} }
if (!client.Connected)
{
return false;
}
NetworkStream stream = client.GetStream(); NetworkStream stream = client.GetStream();
// Buffer to store the response bytes. // Buffer to store the response bytes.