Skip to content

Commit

Permalink
0.2.7.4, exception web reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Sep 19, 2017
1 parent d8cc975 commit 07378d4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
51 changes: 51 additions & 0 deletions CheatSheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using Terraria;
using Terraria.ID;
using Terraria.Localization;
Expand Down Expand Up @@ -472,4 +475,52 @@ internal enum CheatSheetMessageType : byte
RequestFilterNPC,
InformFilterNPC,
}

static class CheatSheetUtilities
{
private static Uri reporturl = new Uri("http://javid.ddns.net/tModLoader/jopojellymods/report.php");

internal static void ReportException(Exception e)
{
ErrorLogger.Log("CheatSheet: " + e.Message + e.StackTrace);
try
{
ReportData data = new ReportData(e);
data.additionaldata = "Loaded Mods: " + string.Join(", ", ModLoader.GetLoadedMods());
string jsonpayload = JsonConvert.SerializeObject(data);
using (WebClient client = new WebClient())
{
var values = new NameValueCollection
{
{ "jsonpayload", jsonpayload },
};
client.UploadValuesAsync(reporturl, "POST", values);
}
}
catch { }
}

class ReportData
{
public string mod;
public string modversion;
public string tmodversion;
public string platform;
public string errormessage;
public string additionaldata;

public ReportData()
{
tmodversion = ModLoader.version.ToString();
modversion = CheatSheet.instance.Version.ToString();
mod = "CheatSheet";
platform = ModLoader.compressedPlatformRepresentation;
}

public ReportData(Exception e) : this()
{
errormessage = e.Message + e.StackTrace;
}
}
}
}
10 changes: 9 additions & 1 deletion CheatSheetWorld.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CheatSheet.Menus;
using System;
using System.IO;
using Terraria;
using Terraria.ModLoader;
Expand All @@ -11,7 +12,14 @@ public override void Initialize()
{
if (!Main.dedServ && Main.LocalPlayer.name != "")
{
(mod as CheatSheet).hotbar.bCycleExtraAccessorySlots.Tooltip = "Extra Accessory Slots: " + Main.LocalPlayer.GetModPlayer<CheatSheetPlayer>(mod).numberExtraAccessoriesEnabled;
try
{
(mod as CheatSheet).hotbar.bCycleExtraAccessorySlots.Tooltip = "Extra Accessory Slots: " + Main.LocalPlayer.GetModPlayer<CheatSheetPlayer>(mod).numberExtraAccessoriesEnabled;
}
catch (Exception e)
{
CheatSheetUtilities.ReportException(e);
}
}

// ((CheatSheet)mod).hotbar.ChangedBossDowner();
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = jopojelly, jofairden
version = 0.2.7.3
version = 0.2.7.4
displayName = Cheat Sheet
homepage = http://forums.terraria.org/index.php?threads/cheat-sheet.41407/
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*
Expand Down

0 comments on commit 07378d4

Please sign in to comment.