forked from PGR/ascnet
uniniform anomaly table fix
This commit is contained in:
parent
c00ea3bd2c
commit
dfaca9d238
|
@ -11,11 +11,10 @@
|
|||
<PackageReference Include="CsvHelper" Version="30.0.1" />
|
||||
<PackageReference Include="MessagePack" Version="2.4.59" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.21.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../AscNet.Table/AscNet.Table.csproj"
|
||||
OutputItemType="Analyzer"
|
||||
ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="../AscNet.Table/AscNet.Table.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
<AdditionalFiles Include="../Resources/table/**" />
|
||||
<ProjectReference Include="..\AscNet.Logging\AscNet.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using MongoDB.Driver;
|
||||
using System.Reflection;
|
||||
using MongoDB.Driver;
|
||||
using Config.Net;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AscNet.Common
|
||||
{
|
||||
|
@ -21,5 +23,35 @@ namespace AscNet.Common
|
|||
);
|
||||
db = mongoClient.GetDatabase(config.Database.Name);
|
||||
}
|
||||
|
||||
public static void DumpTables()
|
||||
{
|
||||
IEnumerable<Type> tableTypes = Assembly.GetAssembly(typeof(Table.client.activity.ActivityGroupTable))!.GetTypes().Where(t => t.BaseType?.Name == "TableReader`2");
|
||||
string baseSavePath = "/PGR_Data/";
|
||||
|
||||
foreach (Type type in tableTypes)
|
||||
{
|
||||
try
|
||||
{
|
||||
object? readerInstance = Activator.CreateInstance(type);
|
||||
readerInstance?.GetType().GetMethod("Load", BindingFlags.Instance | BindingFlags.Public)?.Invoke(readerInstance, null);
|
||||
object? values = type.GetProperty("All", BindingFlags.Instance | BindingFlags.Public)?.GetValue(readerInstance);
|
||||
if (values is not null)
|
||||
{
|
||||
// this will create the folder on ur drive root sorry
|
||||
string savePath = baseSavePath + string.Join("/", type.FullName!.Split(".").Skip(2));
|
||||
if (!Directory.Exists(Path.GetDirectoryName(savePath)))
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(savePath)!);
|
||||
File.WriteAllText(new string(savePath.Take(savePath.Length - 11).ToArray()) + ".json", JsonConvert.SerializeObject(values, Formatting.Indented));
|
||||
Console.WriteLine(type.FullName);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"{type.FullName} failed!, {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using MongoDB.Driver;
|
||||
using AscNet.Table.share.character;
|
||||
using AscNet.Table.share.character.skill;
|
||||
using AscNet.Common.MsgPack;
|
||||
|
||||
namespace AscNet.Common.Database
|
||||
{
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
public class Character
|
||||
{
|
||||
public static readonly IMongoCollection<Character> collection = Common.db.GetCollection<Character>("characters");
|
||||
|
||||
public static Character FromUid(long uid)
|
||||
{
|
||||
return collection.AsQueryable().FirstOrDefault(x => x.Uid == uid) ?? Create(uid);
|
||||
}
|
||||
|
||||
private static Character Create(long uid)
|
||||
{
|
||||
Character character = new()
|
||||
{
|
||||
Uid = uid,
|
||||
Characters = new()
|
||||
};
|
||||
character.AddCharacter(1021001);
|
||||
|
||||
collection.InsertOne(character);
|
||||
|
||||
return character;
|
||||
}
|
||||
|
||||
public void AddCharacter(uint id)
|
||||
{
|
||||
CharacterTable? character = CharacterTableReader.Instance.FromId((int)id);
|
||||
CharacterSkillTable? characterSkill = CharacterSkillTableReader.Instance.FromCharacterId((int)id);
|
||||
if (character is null || characterSkill is null)
|
||||
throw new ArgumentException("Invlid character id!", nameof(id));
|
||||
NotifyCharacterDataList.NotifyCharacterDataListCharacterData characterData = new()
|
||||
{
|
||||
Id = (uint)character.Id,
|
||||
Level = 1,
|
||||
Exp = 0,
|
||||
Quality = 1,
|
||||
InitQuality = 1,
|
||||
Star = 0,
|
||||
Grade = 1,
|
||||
FashionId = (uint)character.DefaultNpcFashtionId,
|
||||
CreateTime = DateTimeOffset.Now.ToUnixTimeSeconds(),
|
||||
TrustLv = 1,
|
||||
TrustExp = 0,
|
||||
Ability = 0,
|
||||
LiberateLv = 1,
|
||||
CharacterHeadInfo = new()
|
||||
{
|
||||
HeadFashionId = (uint)character.DefaultNpcFashtionId,
|
||||
HeadFashionType = 0
|
||||
}
|
||||
};
|
||||
characterData.SkillList.AddRange(characterSkill.SkillGroupId.Take(8).Select(x => new NotifyCharacterDataList.NotifyCharacterDataListCharacterData.NotifyCharacterDataListCharacterDataSkill()
|
||||
{
|
||||
Id = uint.Parse(x.ToString().Take(6).ToArray()),
|
||||
Level = 1
|
||||
}));
|
||||
|
||||
Characters.Add(characterData);
|
||||
}
|
||||
|
||||
[BsonId]
|
||||
public ObjectId Id { get; set; }
|
||||
|
||||
[BsonElement("uid")]
|
||||
[BsonRequired]
|
||||
public long Uid { get; set; }
|
||||
|
||||
[BsonElement("uid")]
|
||||
[BsonRequired]
|
||||
public List<NotifyCharacterDataList.NotifyCharacterDataListCharacterData> Characters { get; set; }
|
||||
}
|
||||
}
|
|
@ -54,8 +54,8 @@ namespace AscNet.Common.MsgPack
|
|||
[MessagePackObject(true)]
|
||||
public partial class BaseEquipLoginData
|
||||
{
|
||||
public object[] BaseEquipList { get; set; }
|
||||
public object[] DressedList { get; set; }
|
||||
public List<dynamic> BaseEquipList { get; set; } = new();
|
||||
public List<dynamic> DressedList { get; set; } = new();
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,8 +75,8 @@ namespace AscNet.Common.MsgPack
|
|||
public long InitQuality { get; set; }
|
||||
public long Star { get; set; }
|
||||
public long Grade { get; set; }
|
||||
public SkillList[] SkillList { get; set; }
|
||||
public object[] EnhanceSkillList { get; set; }
|
||||
public List<SkillList> SkillList { get; set; } = new();
|
||||
public List<dynamic> EnhanceSkillList { get; set; } = new();
|
||||
public long FashionId { get; set; }
|
||||
public long CreateTime { get; set; }
|
||||
public long TrustLv { get; set; }
|
||||
|
@ -109,9 +109,9 @@ namespace AscNet.Common.MsgPack
|
|||
public long Level { get; set; }
|
||||
public long Exp { get; set; }
|
||||
public long Breakthrough { get; set; }
|
||||
public ResonanceInfo[] ResonanceInfo { get; set; }
|
||||
public object[] UnconfirmedResonanceInfo { get; set; }
|
||||
public object[] AwakeSlotList { get; set; }
|
||||
public List<ResonanceInfo> ResonanceInfo { get; set; } = new();
|
||||
public List<object> UnconfirmedResonanceInfo { get; set; } = new();
|
||||
public List<object> AwakeSlotList { get; set; } = new();
|
||||
public bool IsLock { get; set; }
|
||||
public long CreateTime { get; set; }
|
||||
public bool IsRecycle { get; set; }
|
||||
|
@ -136,9 +136,9 @@ namespace AscNet.Common.MsgPack
|
|||
[MessagePackObject(true)]
|
||||
public partial class FubenLoginData
|
||||
{
|
||||
public object[] TreasureData { get; set; }
|
||||
public object[] LastPassStage { get; set; }
|
||||
public object[] ChapterEventInfos { get; set; }
|
||||
public List<object> TreasureData { get; set; } = new();
|
||||
public List<object> LastPassStage { get; set; } = new();
|
||||
public List<object> ChapterEventInfos { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject(true)]
|
||||
|
@ -146,8 +146,8 @@ namespace AscNet.Common.MsgPack
|
|||
{
|
||||
public Dictionary<int, StageDatum> StageData { get; set; }
|
||||
public FubenBaseData FubenBaseData { get; set; }
|
||||
public object[] UnlockHideStages { get; set; }
|
||||
public object[] StageDifficulties { get; set; }
|
||||
public List<object> UnlockHideStages { get; set; } = new();
|
||||
public List<object> StageDifficulties { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject(true)]
|
||||
|
@ -183,16 +183,16 @@ namespace AscNet.Common.MsgPack
|
|||
public long CreateTime { get; set; }
|
||||
public long BestRecordTime { get; set; }
|
||||
public long LastRecordTime { get; set; }
|
||||
public long[] BestCardIds { get; set; }
|
||||
public long[] LastCardIds { get; set; }
|
||||
public List<long> BestCardIds { get; set; } = new();
|
||||
public List<long> LastCardIds { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject(true)]
|
||||
public partial class FubenMainLineData
|
||||
{
|
||||
public long[] TreasureData { get; set; }
|
||||
public List<long> TreasureData { get; set; } = new();
|
||||
public Dictionary<int, long> LastPassStage { get; set; }
|
||||
public object[] MainChapterEventInfos { get; set; }
|
||||
public List<dynamic> MainChapterEventInfos { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject(true)]
|
||||
|
@ -277,7 +277,7 @@ namespace AscNet.Common.MsgPack
|
|||
public partial class SharePlatformConfigList
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long[] SdkId { get; set; }
|
||||
public List<long> SdkId { get; set; } = new();
|
||||
}
|
||||
|
||||
[MessagePackObject(true)]
|
||||
|
@ -313,27 +313,27 @@ namespace AscNet.Common.MsgPack
|
|||
public partial class NotifyLogin
|
||||
{
|
||||
public PlayerData PlayerData { get; set; }
|
||||
public TimeLimitCtrlConfigList[] TimeLimitCtrlConfigList { get; set; }
|
||||
public SharePlatformConfigList[] SharePlatformConfigList { get; set; }
|
||||
public ItemList[] ItemList { get; set; }
|
||||
public Dictionary<int, ItemRecycleData[]> ItemRecycleDict { get; set; }
|
||||
public LoginCharacterList[] CharacterList { get; set; }
|
||||
public EquipList[] EquipList { get; set; }
|
||||
public FashionList[] FashionList { get; set; }
|
||||
public HeadPortraitList[] HeadPortraitList { get; set; }
|
||||
public List<TimeLimitCtrlConfigList> TimeLimitCtrlConfigList { get; set; } = new();
|
||||
public List<SharePlatformConfigList> SharePlatformConfigList { get; set; } = new();
|
||||
public List<ItemList> ItemList { get; set; } = new();
|
||||
public Dictionary<int, List<ItemRecycleData>> ItemRecycleDict { get; set; } = new();
|
||||
public List<LoginCharacterList> CharacterList { get; set; } = new();
|
||||
public List<EquipList> EquipList { get; set; } = new();
|
||||
public List<FashionList> FashionList { get; set; } = new();
|
||||
public List<HeadPortraitList> HeadPortraitList { get; set; } = new();
|
||||
public BaseEquipLoginData BaseEquipLoginData { get; set; }
|
||||
public FubenData FubenData { get; set; }
|
||||
public FubenMainLineData FubenMainLineData { get; set; }
|
||||
public FubenLoginData FubenChapterExtraLoginData { get; set; }
|
||||
public FubenUrgentEventData FubenUrgentEventData { get; set; }
|
||||
public object[] AutoFightRecords { get; set; }
|
||||
public List<dynamic> AutoFightRecords { get; set; } = new();
|
||||
public Dictionary<int, TeamGroupDatum> TeamGroupData { get; set; }
|
||||
public object TeamPrefabData { get; set; }
|
||||
public SignInfo[] SignInfos { get; set; }
|
||||
public object[] AssignChapterRecord { get; set; }
|
||||
public object[] WeaponFashionList { get; set; }
|
||||
public object[] PartnerList { get; set; }
|
||||
public object[] ShieldedProtocolList { get; set; }
|
||||
public dynamic TeamPrefabData { get; set; }
|
||||
public List<SignInfo> SignInfos { get; set; } = new();
|
||||
public List<dynamic> AssignChapterRecord { get; set; } = new();
|
||||
public List<dynamic> WeaponFashionList { get; set; } = new();
|
||||
public List<dynamic> PartnerList { get; set; } = new();
|
||||
public List<dynamic> ShieldedProtocolList { get; set; } = new();
|
||||
public object LimitedLoginData { get; set; }
|
||||
public long UseBackgroundId { get; set; }
|
||||
public FubenLoginData FubenShortStoryLoginData { get; set; }
|
||||
|
@ -2559,7 +2559,7 @@ namespace AscNet.Common.MsgPack
|
|||
public List<NotifyCharacterDataListCharacterDataSkill> SkillList { get; set; } = new();
|
||||
public List<dynamic> EnhanceSkillList { get; set; } = new();
|
||||
public UInt32 FashionId { get; set; }
|
||||
public UInt32 CreateTime { get; set; }
|
||||
public Int64 CreateTime { get; set; }
|
||||
public Int32 TrustLv { get; set; }
|
||||
public Int32 TrustExp { get; set; }
|
||||
public Int32 Ability { get; set; }
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace AscNet.Common.Util
|
|||
public abstract class TableReader<TSelf, TScheme>
|
||||
{
|
||||
public List<TScheme> All { get; set; }
|
||||
private readonly Logger c = new(typeof(TableReader<TSelf, TScheme>), nameof(TableReader<TSelf, TScheme>), LogLevel.DEBUG, LogLevel.DEBUG);
|
||||
protected abstract string FilePath { get; }
|
||||
private readonly Logger c = new(typeof(TableReader<TSelf, TScheme>), nameof(TableReader<TSelf, TScheme>), LogLevel.DEBUG, LogLevel.DEBUG);
|
||||
private static TSelf _instance;
|
||||
|
||||
public static TSelf Instance
|
||||
|
@ -26,7 +26,7 @@ namespace AscNet.Common.Util
|
|||
}
|
||||
}
|
||||
|
||||
protected abstract void Load();
|
||||
public abstract void Load();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ namespace AscNet.Table
|
|||
string file = $@"// <auto-generated/>
|
||||
namespace AscNet.Table{ns}
|
||||
{{
|
||||
#nullable enable
|
||||
public class {Path.GetFileName(table.Path).Split('.').First()}Table
|
||||
{{
|
||||
{string.Join("\r\n\t\t", properties.Values)}
|
||||
|
@ -87,14 +88,34 @@ namespace AscNet.Table{ns}
|
|||
public class {Path.GetFileName(table.Path).Split('.').First()}TableReader : global::AscNet.Common.Util.TableReader<{Path.GetFileName(table.Path).Split('.').First()}TableReader, {Path.GetFileName(table.Path).Split('.').First()}Table>
|
||||
{{
|
||||
protected override string FilePath {{ get {{ return ""{string.Join("", table.Path.Replace("\\", "/").Split(new string[] {"/Resources/"}, StringSplitOptions.None).Skip(1))}""; }} }}
|
||||
protected override void Load()
|
||||
|
||||
public override void Load()
|
||||
{{
|
||||
string tsvStr = global::System.Text.Encoding.UTF8.GetString(global::System.IO.File.ReadAllBytes(FilePath).Skip(128).ToArray());
|
||||
using var reader = new global::System.IO.StringReader(tsvStr.Replace(""\t"", "",""));
|
||||
string[] tsvValues = tsvStr.Split('\t');
|
||||
string[] csvValues = new string[tsvValues.Length];
|
||||
for (int i = 0; i < tsvValues.Length; i++)
|
||||
{{
|
||||
if (tsvValues[i].Contains("",""))
|
||||
{{
|
||||
csvValues[i] = ""\"""" + tsvValues[i].Replace(""\"""", ""\""\"""") + ""\"""";
|
||||
}}
|
||||
else
|
||||
{{
|
||||
csvValues[i] = tsvValues[i];
|
||||
}}
|
||||
}}
|
||||
using var reader = new global::System.IO.StringReader(string.Join("","", csvValues));
|
||||
using var csv = new global::CsvHelper.CsvReader(reader, new global::CsvHelper.Configuration.CsvConfiguration(global::System.Globalization.CultureInfo.InvariantCulture) {{ BadDataFound = null, HeaderValidated = null, MissingFieldFound = null }});
|
||||
csv.Context.RegisterClassMap<{Path.GetFileName(table.Path).Split('.').First()}TableMap>();
|
||||
All = csv.GetRecords<{Path.GetFileName(table.Path).Split('.').First()}Table>().ToList();
|
||||
}}
|
||||
{string.Join("\r\n", properties.Values.Select(x => x.Split(' ')).Where(x => !x[1].Contains("<")).Select(property => $@"
|
||||
public {Path.GetFileName(table.Path).Split('.').First()}Table? From{property[2]}({property[1]} val)
|
||||
{{
|
||||
return All.FirstOrDefault(x => x.{property[2]} == val);
|
||||
}}
|
||||
"))}
|
||||
}}
|
||||
|
||||
public sealed class {Path.GetFileName(table.Path).Split('.').First()}TableMap : global::CsvHelper.Configuration.ClassMap<{Path.GetFileName(table.Path).Split('.').First()}Table>
|
||||
|
@ -106,10 +127,9 @@ namespace AscNet.Table{ns}
|
|||
Map(m => m.{x}).Convert(args =>
|
||||
{{
|
||||
{properties[x].Split(' ')[1]} tags = new {properties[x].Split(' ')[1]}();
|
||||
|
||||
for (int i = 1; i <= {listCount[x]}; i++)
|
||||
{(nameList.Contains($"{x}[0]") ? $"for (int i = 0; i < {listCount[x]}; i++)" : $"for (int i = 1; i <= {listCount[x]}; i++)")}
|
||||
{{
|
||||
string tagValue = args.Row.GetField<string>($""{x}[{{i}}]"");
|
||||
string? tagValue = args.Row.GetField<string>($""{x}[{{i}}]"");
|
||||
if (!string.IsNullOrEmpty(tagValue))
|
||||
{{
|
||||
{(properties[x].Split('<')[1].StartsWith("global::System.Int32") ? @"
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace AscNet
|
|||
PacketFactory.LoadPacketHandlers();
|
||||
Task.Run(Server.Instance.Start);
|
||||
SDKServer.SDKServer.Main(args);
|
||||
Common.Common.DumpTables();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue