Skip to content

Commit 4a4d4da

Browse files
committed
Added null checks and lowered timeout if assets are disabled.
1 parent 46ee62e commit 4a4d4da

File tree

6 files changed

+35
-30
lines changed

6 files changed

+35
-30
lines changed

WindowsFormsApplication6/Form1.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Net.WebSockets;
1010
using System.Threading;
1111
using System.IO;
12-
using Newtonsoft.Json;
1312
using System.Net;
1413

1514
namespace WindowsFormsApplication6

WindowsFormsApplication6/Form1.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
<metadata name="fileSystemWatcher1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123+
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
124+
<value>39</value>
125+
</metadata>
123126
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124127
<value>176, 17</value>
125128
</metadata>

WindowsFormsApplication6/Managers/HelperClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public string GetFile(string ServerName, string ServerPort, string filepath, str
115115

116116
webRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
117117
webRequest.AllowWriteStreamBuffering = true;
118-
webRequest.Timeout = 30000;
118+
webRequest.Timeout = 1000;
119119
webRequest.Referer = GetFakeReferer(ServerName, ServerPort);
120120
webRequest.Headers.Add("sid", sid);
121121

WindowsFormsApplication6/Managers/MapManager.cs

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,41 +77,44 @@ public PictureBox DrawMonuments(string ServerName, string ServerPort, List<Model
7777

7878
HelperClass HelpMgr = new HelperClass();
7979

80-
OutPut.AppendText(Environment.NewLine + "Total World Monumnets:" + Monumentlst.Count.ToString());
80+
if (Monumentlst != null)
81+
{
82+
OutPut.AppendText(Environment.NewLine + "Total World Monumnets:" + Monumentlst.Count.ToString());
8183

82-
foreach (Models.world.Monument Monument in Monumentlst)
83-
{
84+
foreach (Models.world.Monument Monument in Monumentlst)
85+
{
8486

85-
// Output the load of image
86-
OutPut.AppendText(Environment.NewLine + "Attempting to draw [" + Monument.name + "]: " + Monument.displayName);
87+
// Output the load of image
88+
OutPut.AppendText(Environment.NewLine + "Attempting to draw [" + Monument.name + "]: " + Monument.displayName);
8789

88-
string ImgPath = BuildMonumentsImagePath(Monument);
89-
Image ObjectImg = null;
90+
string ImgPath = BuildMonumentsImagePath(Monument);
91+
Image ObjectImg = null;
9092

91-
// Check if image is cached
92-
if (File.Exists("." + ImgPath))
93-
{
94-
// Load file from cache
95-
ObjectImg = Image.FromFile("." + ImgPath);
96-
} else
97-
{
93+
// Check if image is cached
94+
if (File.Exists("." + ImgPath))
95+
{
96+
// Load file from cache
97+
ObjectImg = Image.FromFile("." + ImgPath);
98+
} else
99+
{
98100

99-
// Try to get image for object
100-
ObjectImg = GetImage(RustIOServer, "80", BuildMonumentsImagePath(Monument));
101+
// Try to get image for object
102+
ObjectImg = GetImage(RustIOServer, "80", BuildMonumentsImagePath(Monument));
101103

102-
// Cache Image
103-
ObjectImg.Save("." + ImgPath);
104-
}
104+
// Cache Image
105+
ObjectImg.Save("." + ImgPath);
106+
}
105107

106-
// Make sure its not null
107-
if (ObjectImg != null)
108-
{
108+
// Make sure its not null
109+
if (ObjectImg != null)
110+
{
109111

110-
// Draw Monuments
111-
MapImg = DrawMonument(Monument, ObjectImg, MapImg, ServerStatus);
112-
}
112+
// Draw Monuments
113+
MapImg = DrawMonument(Monument, ObjectImg, MapImg, ServerStatus);
114+
}
113115

114-
}
116+
}
117+
}
115118

116119
return MapImg;
117120
}

WindowsFormsApplication6/WindowsFormsApplication6.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</PropertyGroup>
5656
<ItemGroup>
5757
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
58-
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
58+
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
5959
</Reference>
6060
<Reference Include="SteamKit2">
6161
<HintPath>..\packages\SteamKit2\SteamKit2.dll</HintPath>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
3+
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net472" />
44
</packages>

0 commit comments

Comments
 (0)