Merge branch 'main' of https://github.com/sp-tarkov/server-csharp
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
using Core.Utils.Json.Converters;
|
||||
|
||||
namespace Core.Models.Eft.Common;
|
||||
|
||||
public class PmcData : BotBase
|
||||
{
|
||||
[JsonPropertyName("Prestige")]
|
||||
[JsonConverter(typeof(ArrayToObjectFactoryConverter))]
|
||||
public Tables.Prestige Prestige { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ public class Info
|
||||
public string? Voice { get; set; }
|
||||
public double? Level { get; set; }
|
||||
public double? Experience { get; set; }
|
||||
[JsonConverter(typeof(StringToNumberFactoryConverter))]
|
||||
public long? RegistrationDate { get; set; }
|
||||
public string? GameVersion { get; set; }
|
||||
public double? AccountType { get; set; }
|
||||
@@ -181,6 +182,7 @@ public class Info
|
||||
|
||||
[JsonPropertyName("isMigratedSkills")]
|
||||
public bool? IsMigratedSkills { get; set; }
|
||||
public double? PrestigeLevel { get; set; }
|
||||
}
|
||||
|
||||
public class BotInfoSettings
|
||||
@@ -219,6 +221,7 @@ public class Customization
|
||||
public string? Body { get; set; }
|
||||
public string? Feet { get; set; }
|
||||
public string? Hands { get; set; }
|
||||
public string? DogTag { get; set; }
|
||||
}
|
||||
|
||||
public class BotBaseHealth
|
||||
@@ -518,6 +521,7 @@ public class Hideout
|
||||
|
||||
[JsonPropertyName("sptUpdateLastRunTimestamp")]
|
||||
public long? SptUpdateLastRunTimestamp { get; set; }
|
||||
public Dictionary<string, string>? Customization { get; set; }
|
||||
}
|
||||
|
||||
public class HideoutCounters
|
||||
@@ -751,6 +755,7 @@ public class Bonus
|
||||
public string? Id { get; set; }
|
||||
|
||||
[JsonPropertyName("type")]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public BonusType? Type { get; set; }
|
||||
|
||||
[JsonPropertyName("templateId")]
|
||||
|
||||
@@ -197,6 +197,10 @@ public class TraderRepair
|
||||
[JsonPropertyName("quality")]
|
||||
[JsonConverter(typeof(StringToNumberFactoryConverter))]
|
||||
public double? Quality { get; set; }
|
||||
|
||||
[JsonPropertyName("price_rate")]
|
||||
public double? PriceRate { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class TraderAssort
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Core.Models.Spt.Services;
|
||||
public class TraderServiceModel
|
||||
{
|
||||
[JsonPropertyName("serviceType")]
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public TraderServiceType? ServiceType { get; set; }
|
||||
|
||||
[JsonPropertyName("itemsToPay")]
|
||||
@@ -27,5 +28,5 @@ public class TraderServiceRequirementsModel
|
||||
public List<string>? CompletedQuests { get; set; }
|
||||
|
||||
[JsonPropertyName("standings")]
|
||||
public Dictionary<string, int>? Standings { get; set; }
|
||||
}
|
||||
public Dictionary<string, double>? Standings { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Annotations;
|
||||
@@ -11,6 +10,8 @@ public class ImporterUtil
|
||||
{
|
||||
private readonly FileUtil _fileUtil;
|
||||
|
||||
private readonly HashSet<string> filesToIgnore = ["bearsuits.json", "usecsuits.json", "archivedquests.json"];
|
||||
|
||||
public ImporterUtil(FileUtil fileUtil)
|
||||
{
|
||||
_fileUtil = fileUtil;
|
||||
@@ -39,8 +40,7 @@ public class ImporterUtil
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (_fileUtil.GetFileExtension(file) != "json") continue;
|
||||
// to skip ArchivedQuests.json
|
||||
if (file.ToLower().Contains("archived")) continue;
|
||||
if (filesToIgnore.Contains(Path.GetFileName(file).ToLower())) continue;
|
||||
tasks.Add(
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
|
||||
@@ -25,7 +25,24 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
|
||||
var value = reader.GetString();
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return default;
|
||||
goto case JsonTokenType.Number;
|
||||
var type = typeToConvert;
|
||||
try
|
||||
{
|
||||
if (typeToConvert.IsGenericType &&
|
||||
typeToConvert.GetGenericTypeDefinition() == typeof(Nullable<>))
|
||||
{
|
||||
type = typeToConvert.GenericTypeArguments[0];
|
||||
}
|
||||
return (T) type.GetMethods().First(m =>
|
||||
m.Name == "Parse" && m.GetParameters().Length == 1 &&
|
||||
m.GetParameters().First().ParameterType == typeof(string)).Invoke(null, [value]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Tried to convert {value} into {type.Name} but failed to parse it, null value will be used instead.");
|
||||
}
|
||||
|
||||
return default;
|
||||
case JsonTokenType.Number:
|
||||
using (var jsonDocument = JsonDocument.ParseValue(ref reader))
|
||||
{
|
||||
@@ -46,4 +63,4 @@ public class StringToNumberFactoryConverter : JsonConverterFactory
|
||||
JsonSerializer.Serialize(writer, value, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user