Skip to content

Commit

Permalink
JsonConvert Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zeng-github01 committed Jan 19, 2025
1 parent 3f66ac5 commit a19e8db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions DatabaseManager.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using Google.Protobuf;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using Rocket.Core.Logging;
using SDG.Framework.IO.Deserialization;
using SDG.Unturned;
using Steamworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;

namespace PlayerInfoLibrary
{
Expand Down Expand Up @@ -609,7 +610,7 @@ private string ParseOption(OptionType optionType)

private PlayerData BuildPlayerData(MySqlDataReader reader)
{
return new PlayerData((CSteamID)reader.GetUInt64("SteamID"), reader.GetString("SteamName"), reader.GetString("CharName"), Parser.getIPFromUInt32(reader.GetUInt32("IP")), JsonSerializer.Deserialize<List<string>>(reader.GetString("HWID")), reader.GetInt64("LastLoginGlobal").FromTimeStamp(), reader.GetUInt16("LastServerID"), !reader.IsDBNull("LastServerName") ? reader.GetString("LastServerName") : string.Empty, !reader.IsDBNull("ServerID") ? reader.GetUInt16("ServerID") : (ushort)0, !reader.IsDBNull("LastLoginLocal") ? reader.GetInt64("LastLoginLocal").FromTimeStamp() : (0L).FromTimeStamp(), !reader.IsDBNull("CleanedBuildables") ? reader.GetBoolean("CleanedBuildables") : false, !reader.IsDBNull("CleanedPlayerData") ? reader.GetBoolean("CleanedPlayerData") : false, reader.GetInt32("TotalPlayTime"));
return new PlayerData((CSteamID)reader.GetUInt64("SteamID"), reader.GetString("SteamName"), reader.GetString("CharName"), Parser.getIPFromUInt32(reader.GetUInt32("IP")), JsonConvert.DeserializeObject<List<string>>(reader.GetString("HWID")), reader.GetInt64("LastLoginGlobal").FromTimeStamp(), reader.GetUInt16("LastServerID"), !reader.IsDBNull("LastServerName") ? reader.GetString("LastServerName") : string.Empty, !reader.IsDBNull("ServerID") ? reader.GetUInt16("ServerID") : (ushort)0, !reader.IsDBNull("LastLoginLocal") ? reader.GetInt64("LastLoginLocal").FromTimeStamp() : (0L).FromTimeStamp(), !reader.IsDBNull("CleanedBuildables") ? reader.GetBoolean("CleanedBuildables") : false, !reader.IsDBNull("CleanedPlayerData") ? reader.GetBoolean("CleanedPlayerData") : false, reader.GetInt32("TotalPlayTime"));
}

// Cleanup section.
Expand Down Expand Up @@ -787,7 +788,7 @@ internal void SaveToDB(PlayerData pdata, bool retry = false)
command.Parameters.AddWithValue("@steamname", pdata.SteamName.Truncate(200));
command.Parameters.AddWithValue("@charname", pdata.CharacterName.Truncate(200));
command.Parameters.AddWithValue("@ip", Parser.getUInt32FromIP(pdata.IP));
command.Parameters.AddWithValue("@hwid", JsonSerializer.Serialize(pdata.HWID));
command.Parameters.AddWithValue("@hwid", JsonConvert.SerializeObject(pdata.HWID));
command.Parameters.AddWithValue("@instanceid", pdata.ServerID);
command.Parameters.AddWithValue("@lastinstanceid", pdata.LastServerID);
command.Parameters.AddWithValue("@lastloginglobal", pdata.LastLoginGlobal.ToTimeStamp());
Expand Down
5 changes: 4 additions & 1 deletion PlayerInfoLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<Reference Include="MySql.Data, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>packages\MySql.Data.8.0.28\lib\net48\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>D:\Program Files (x86)\Steam\steamapps\common\U3DS\Unturned_Data\Managed\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Rocket.API">
<HintPath>lib\Rocket.API.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -97,7 +101,6 @@
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL" />
<Reference Include="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.4.2.0")]
[assembly: AssemblyFileVersion("1.4.2.0")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]

0 comments on commit a19e8db

Please sign in to comment.