forked from PGR/ascnet
CharacterCommand works perfectly i guess
This commit is contained in:
parent
8bcb27b3ad
commit
ea62c7a9c8
|
@ -1,5 +1,8 @@
|
|||
using AscNet.Common.MsgPack;
|
||||
using AscNet.Table.share.character;
|
||||
using AscNet.Common.Database;
|
||||
using AscNet.Common.Util;
|
||||
using AscNet.Common.MsgPack;
|
||||
using AscNet.GameServer.Handlers;
|
||||
using AscNet.Table.V2.share.character;
|
||||
|
||||
namespace AscNet.GameServer.Commands
|
||||
{
|
||||
|
@ -18,33 +21,33 @@ namespace AscNet.GameServer.Commands
|
|||
|
||||
public override void Execute()
|
||||
{
|
||||
uint id = 0;
|
||||
|
||||
uint.TryParse(Target, out id);
|
||||
int id = Miscs.ParseIntOr(Target);
|
||||
List<AddCharacterRet> rets = new();
|
||||
|
||||
switch (Op)
|
||||
{
|
||||
case "add":
|
||||
if (Target == "all")
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
foreach (CharacterTable character in CharacterTableReader.Instance.All)
|
||||
{
|
||||
if (session.character.Characters.FirstOrDefault(c => c.Id == character.Id) is not null)
|
||||
session.character.AddCharacter((uint)character.Id);
|
||||
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}).Start();
|
||||
}
|
||||
else if (id > 0)
|
||||
{
|
||||
if (session.character.Characters.Find(c => c.Id == id) == null)
|
||||
session.character.AddCharacter(id);
|
||||
foreach (var characterData in TableReaderV2.Parse<CharacterTable>().Where(x => !session.character.Characters.Any(y => y.Id == x.Id)))
|
||||
rets.Add(session.character.AddCharacter((uint)characterData.Id));
|
||||
}
|
||||
else
|
||||
throw new ArgumentException("Invalid Target / ID!");
|
||||
{
|
||||
if (!session.character.Characters.Any(c => c.Id == id))
|
||||
rets.Add(session.character.AddCharacter((uint)id));
|
||||
}
|
||||
|
||||
NotifyEquipDataList notifyEquipData = new();
|
||||
FashionSyncNotify fashionSync = new();
|
||||
NotifyCharacterDataList notifyCharacterData = new();
|
||||
|
||||
notifyEquipData.EquipDataList.AddRange(rets.Select(x => x.Equip));
|
||||
fashionSync.FashionList.AddRange(rets.Select(x => x.Fashion));
|
||||
notifyCharacterData.CharacterDataList.AddRange(rets.Select(x => x.Character));
|
||||
session.SendPush(notifyEquipData);
|
||||
session.SendPush(fashionSync);
|
||||
session.SendPush(notifyCharacterData);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException("Invalid operation!");
|
||||
|
|
|
@ -89,6 +89,7 @@ namespace AscNet.GameServer.Handlers
|
|||
fashionSync.FashionList.Add(addRet.Fashion);
|
||||
notifyCharacterData.CharacterDataList.Add(addRet.Character);
|
||||
session.SendPush(notifyEquipData);
|
||||
session.SendPush(fashionSync);
|
||||
session.SendPush(notifyCharacterData);
|
||||
}
|
||||
catch (ServerCodeException ex)
|
||||
|
|
Loading…
Reference in New Issue