From 348b62f5f71ff4c9f8f8bad03d47095266832366 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 11 Jul 2017 18:35:22 +1000 Subject: [PATCH] Fix /gen with heightmap theme erroring when used from console. --- MCGalaxy/Generator/HeightmapGen.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MCGalaxy/Generator/HeightmapGen.cs b/MCGalaxy/Generator/HeightmapGen.cs index bb18c6fc4..0c5ee9b05 100644 --- a/MCGalaxy/Generator/HeightmapGen.cs +++ b/MCGalaxy/Generator/HeightmapGen.cs @@ -38,7 +38,8 @@ namespace MCGalaxy.Generator { try { using (WebClient client = HttpUtil.CreateWebClient()) { Player.Message(p, "Downloading file from: &f" + url); - client.DownloadFile(uri, dir + "tempImage_" + p.name + ".bmp"); + string user = p == null ? "(console)" : p.name; + client.DownloadFile(uri, dir + "tempImage_" + user + ".bmp"); } Player.Message(p, "Finished downloading image."); return true; @@ -72,11 +73,12 @@ namespace MCGalaxy.Generator { Level lvl = args.Level; if (args.Args == "") { Player.Message(p, "You need to provide a url for the image."); return false; } - if (!DownloadImage(args.Args, "extra/heightmap/", p )) return false; - Bitmap bmp = ReadBitmap("tempImage_" + p.name, "extra/heightmap/", p); + if (!DownloadImage(args.Args, "extra/heightmap/", p )) return false; + string user = p == null ? "(console)" : p.name; + Bitmap bmp = ReadBitmap("tempImage_" + user, "extra/heightmap/", p); if (bmp == null) return false; - int index = 0, oneY = lvl.Width * lvl.Length; + int index = 0, oneY = lvl.Width * lvl.Length; using (bmp) { if (lvl.Width != bmp.Width || lvl.Length != bmp.Height) { Player.Message(p, "The size of the heightmap is {0} by {1}.", bmp.Width, bmp.Height);