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.Common.Database;
|
||||||
using AscNet.Table.share.character;
|
using AscNet.Common.Util;
|
||||||
|
using AscNet.Common.MsgPack;
|
||||||
|
using AscNet.GameServer.Handlers;
|
||||||
|
using AscNet.Table.V2.share.character;
|
||||||
|
|
||||||
namespace AscNet.GameServer.Commands
|
namespace AscNet.GameServer.Commands
|
||||||
{
|
{
|
||||||
|
@ -18,33 +21,33 @@ namespace AscNet.GameServer.Commands
|
||||||
|
|
||||||
public override void Execute()
|
public override void Execute()
|
||||||
{
|
{
|
||||||
uint id = 0;
|
int id = Miscs.ParseIntOr(Target);
|
||||||
|
List<AddCharacterRet> rets = new();
|
||||||
uint.TryParse(Target, out id);
|
|
||||||
|
|
||||||
switch (Op)
|
switch (Op)
|
||||||
{
|
{
|
||||||
case "add":
|
case "add":
|
||||||
if (Target == "all")
|
if (Target == "all")
|
||||||
{
|
{
|
||||||
new Thread(() =>
|
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));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
else
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new InvalidOperationException("Invalid operation!");
|
throw new InvalidOperationException("Invalid operation!");
|
||||||
|
|
|
@ -89,6 +89,7 @@ namespace AscNet.GameServer.Handlers
|
||||||
fashionSync.FashionList.Add(addRet.Fashion);
|
fashionSync.FashionList.Add(addRet.Fashion);
|
||||||
notifyCharacterData.CharacterDataList.Add(addRet.Character);
|
notifyCharacterData.CharacterDataList.Add(addRet.Character);
|
||||||
session.SendPush(notifyEquipData);
|
session.SendPush(notifyEquipData);
|
||||||
|
session.SendPush(fashionSync);
|
||||||
session.SendPush(notifyCharacterData);
|
session.SendPush(notifyCharacterData);
|
||||||
}
|
}
|
||||||
catch (ServerCodeException ex)
|
catch (ServerCodeException ex)
|
||||||
|
|
Loading…
Reference in New Issue