mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 17:04:13 +00:00
Added character fragments
To address the issue where RspLogin was becoming too large to allow logins, I changed the system to send a portion of the information via NtfSyncPlayer.
This commit is contained in:
@@ -28,6 +28,7 @@ public class SuppliesExcel : ExcelResource
|
||||
public override void Loaded()
|
||||
{
|
||||
GameData.SuppliesData[GetId()] = this;
|
||||
GameData.AllSuppliesData.Add(this);
|
||||
}
|
||||
|
||||
private static int ReadInt(JToken? token)
|
||||
|
||||
@@ -8,6 +8,7 @@ public static class GameData
|
||||
public static Dictionary<uint, WeaponExcel> WeaponData { get; private set; } = [];
|
||||
public static Dictionary<uint, CardSkinExcel> CardSkinData { get; private set; } = [];
|
||||
public static Dictionary<uint, SuppliesExcel> SuppliesData { get; private set; } = [];
|
||||
public static List<SuppliesExcel> AllSuppliesData { get; private set; } = [];
|
||||
public static Dictionary<int, UpgradeExpExcel> UpgradeExpData { get; private set; } = [];
|
||||
public static Dictionary<int, BreakLevelLimitExcel> BreakLevelLimitData { get; private set; } = [];
|
||||
public static Dictionary<int, RecycleExcel> RecycleData { get; private set; } = [];
|
||||
|
||||
@@ -138,11 +138,14 @@ public class InventoryManager(PlayerInstance player) : BasePlayerManager(player)
|
||||
return InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||
}
|
||||
|
||||
private static uint GetSuppliesMaxCount(SuppliesExcel suppliesData) =>
|
||||
suppliesData.Genre == 5 && suppliesData.Detail == 4 ? 999999u : 99999u;
|
||||
|
||||
public async ValueTask<BaseGameItemInfo?> AddSuppliesItem(SuppliesExcel suppliesData, uint count)
|
||||
{
|
||||
var templateId = GameResourceTemplateId.FromGdpl(suppliesData.Genre, suppliesData.Detail, suppliesData.Particular, suppliesData.Level);
|
||||
|
||||
uint maxCount = suppliesData.GMnum > 0 ? suppliesData.GMnum : 99999;
|
||||
uint maxCount = GetSuppliesMaxCount(suppliesData);
|
||||
uint giveCount = Math.Min(count, maxCount);
|
||||
|
||||
var existing = InventoryData.Items.Values.FirstOrDefault(x => x.TemplateId == templateId);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MikuSB.Data;
|
||||
using MikuSB.Database;
|
||||
using MikuSB.Database.Account;
|
||||
using MikuSB.Database.Inventory;
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.Enums.Item;
|
||||
using MikuSB.GameServer.Command;
|
||||
@@ -69,7 +70,7 @@ public class PlayerInstance(PlayerGameData data)
|
||||
{
|
||||
await CharacterManager.AddCharacter((ItemTypeEnum)card.Genre, card.Detail, card.Particular, card.Level);
|
||||
}
|
||||
foreach (var supplies in GameData.SuppliesData.Values)
|
||||
foreach (var supplies in GameData.AllSuppliesData)
|
||||
{
|
||||
await InventoryManager.AddSuppliesItem(supplies, 90000);
|
||||
}
|
||||
@@ -138,6 +139,18 @@ public class PlayerInstance(PlayerGameData data)
|
||||
{
|
||||
if (!Initialized) await InitialPlayerManager();
|
||||
await CharacterManager.RepairCharacterWeapons();
|
||||
await EnsureSupplies();
|
||||
}
|
||||
|
||||
public IEnumerable<BaseGameItemInfo> GetSupplyItems() =>
|
||||
InventoryManager.InventoryData.Items.Values.Where(x => (x.TemplateId & 0xFFFF) == 5);
|
||||
|
||||
private async ValueTask EnsureSupplies()
|
||||
{
|
||||
foreach (var supplies in GameData.AllSuppliesData)
|
||||
{
|
||||
await InventoryManager.AddSuppliesItem(supplies, 90000);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask OnLogin()
|
||||
@@ -228,7 +241,8 @@ public class PlayerInstance(PlayerGameData data)
|
||||
Solutions = { LineupManager.LineupData.LineupInfo.Values.Select(x => x.ToProto()) },
|
||||
};
|
||||
|
||||
foreach (var item in InventoryManager.InventoryData.Items.Values) proto.Items.Add(item.ToProto());
|
||||
foreach (var item in InventoryManager.InventoryData.Items.Values)
|
||||
if ((item.TemplateId & 0xFFFF) != 5) proto.Items.Add(item.ToProto());
|
||||
foreach (var weapon in InventoryManager.InventoryData.Weapons.Values) proto.Items.Add(weapon.ToProto());
|
||||
foreach (var skin in InventoryManager.InventoryData.Skins.Values) proto.Items.Add(skin.ToProto());
|
||||
foreach (var chara in CharacterManager.CharacterData.Characters) proto.Items.Add(chara.ToProto());
|
||||
|
||||
@@ -3,6 +3,7 @@ using MikuSB.Database;
|
||||
using MikuSB.Database.Account;
|
||||
using MikuSB.Database.Player;
|
||||
using MikuSB.GameServer.Game.Player;
|
||||
using MikuSB.GameServer.Server.CallGS;
|
||||
using MikuSB.GameServer.Server.Packet.Send.Friend;
|
||||
using MikuSB.GameServer.Server.Packet.Send.Login;
|
||||
using MikuSB.Proto;
|
||||
@@ -47,6 +48,13 @@ public class HandlerReqLogin : Handler
|
||||
await connection.Player.OnEnterGame();
|
||||
connection.Player.Connection = connection;
|
||||
await connection.SendPacket(new PacketRspLogin(connection.Player!));
|
||||
|
||||
var supplySync = new MikuSB.Proto.NtfSyncPlayer();
|
||||
foreach (var item in connection.Player.GetSupplyItems())
|
||||
supplySync.Items.Add(item.ToProto());
|
||||
if (supplySync.Items.Count > 0)
|
||||
await CallGSRouter.SendScript(connection, "", "{}", supplySync);
|
||||
|
||||
await connection.Player.OnHeartBeat();
|
||||
await connection.SendPacket(new PacketNtfUpdateFriend(connection.Player!));
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using MikuSB.GameServer.Game.Player;
|
||||
using MikuSB.TcpSharp;
|
||||
using MikuSB.Proto;
|
||||
using MikuSB.Util;
|
||||
using MikuSB.Util.Extensions;
|
||||
|
||||
namespace MikuSB.GameServer.Server.Packet.Send.Login;
|
||||
|
||||
public class PacketRspLogin : BasePacket
|
||||
{
|
||||
private static readonly Logger Logger = new("RspLogin");
|
||||
|
||||
public PacketRspLogin(PlayerInstance player) : base(CmdIds.RspLogin)
|
||||
{
|
||||
var proto = new RspLogin
|
||||
@@ -18,6 +21,9 @@ public class PacketRspLogin : BasePacket
|
||||
NeedRename = false
|
||||
};
|
||||
|
||||
SetData(proto);
|
||||
var bytes = Google.Protobuf.MessageExtensions.ToByteArray(proto);
|
||||
Logger.Info($"RspLogin proto size: {bytes.Length} bytes (limit: 65535)");
|
||||
|
||||
SetData(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user