Fix for null reference exceptions from REST

This commit is contained in:
White 2017-01-11 19:42:38 +10:30
parent f264e2b060
commit fe670bc18f

View file

@ -24,6 +24,7 @@ using HttpServer;
using TShockAPI;
using TShockAPI.DB;
using Microsoft.Xna.Framework;
using Terraria;
namespace Rests
{
@ -199,6 +200,13 @@ namespace Rests
{ Error = string.Format("Not authorized. User \"{0}\" has no access to use the specified API endpoint.", tokenData.Username) };
}
//Main.rand being null can cause issues in command execution.
//This should solve that
if (Main.rand == null)
{
Main.rand = new Terraria.Utilities.UnifiedRandom();
}
object result = secureCmd.Execute(verbs, parms, tokenData, request, context);
if (cmd.DoLog && TShock.Config.LogRest)
TShock.Utils.SendLogs(string.Format(