mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-16 17:04:44 +01:00
Fix inventory system crash
Forgot to assign position value
This commit is contained in:
@@ -137,7 +137,7 @@ namespace nksrv.Utils
|
||||
}
|
||||
public class CoreInfo
|
||||
{
|
||||
public int DbVersion = 0;
|
||||
public int DbVersion = 2;
|
||||
public List<User> Users = [];
|
||||
|
||||
public List<AccessToken> LauncherAccessTokens = [];
|
||||
@@ -187,6 +187,20 @@ namespace nksrv.Utils
|
||||
}
|
||||
Console.WriteLine("Database update completed");
|
||||
}
|
||||
else if (Instance.DbVersion == 1)
|
||||
{
|
||||
Console.WriteLine("Starting database update...");
|
||||
// there was a bug where equipment position was not saved, so remove all items from each characters
|
||||
Instance.DbVersion = 2;
|
||||
foreach (var user in Instance.Users)
|
||||
{
|
||||
foreach (var f in user.Items.ToList())
|
||||
{
|
||||
f.Csn = 0;
|
||||
}
|
||||
}
|
||||
Console.WriteLine("Database update completed");
|
||||
}
|
||||
Save();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
|
||||
|
||||
using nksrv.StaticInfo;
|
||||
using Swan.Logging;
|
||||
using System.Reflection;
|
||||
|
||||
namespace nksrv.Utils
|
||||
{
|
||||
public class NetUtils
|
||||
@@ -17,5 +22,61 @@ namespace nksrv.Utils
|
||||
Tid = item.ItemType
|
||||
};
|
||||
}
|
||||
|
||||
public static List<NetUserItemData> GetUserItems(User user)
|
||||
{
|
||||
List<NetUserItemData> ret = new();
|
||||
Dictionary<int, NetUserItemData> itemDictionary = new Dictionary<int, NetUserItemData>();
|
||||
|
||||
foreach (var item in user.Items.ToList())
|
||||
{
|
||||
if (item.Csn == 0)
|
||||
{
|
||||
if (itemDictionary.ContainsKey(item.ItemType))
|
||||
{
|
||||
itemDictionary[item.ItemType].Count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemDictionary[item.ItemType] = new NetUserItemData() { Count = item.Count, Tid = item.ItemType, Csn = item.Csn, Lv = item.Level, Exp = item.Exp, Corporation = item.Corp, Isn = item.Isn, Position = item.Position };
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var newItem = new NetUserItemData() { Count = item.Count, Tid = item.ItemType, Csn = item.Csn, Lv = item.Level, Exp = item.Exp, Corporation = item.Corp, Isn = item.Isn, Position = item.Position };
|
||||
itemDictionary[item.ItemType] = newItem;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static int GetItemPos(User user, long isn)
|
||||
{
|
||||
foreach (var item in user.Items)
|
||||
{
|
||||
if (item.Isn == isn)
|
||||
{
|
||||
var subType = StaticDataParser.Instance.GetItemSubType(item.ItemType);
|
||||
switch(subType)
|
||||
{
|
||||
case "Module_A":
|
||||
return 0;
|
||||
case "Module_B":
|
||||
return 1;
|
||||
case "Module_C":
|
||||
return 2;
|
||||
case "Module_D":
|
||||
return 3;
|
||||
default:
|
||||
Logger.Warn("Unknown item subtype: " + subType);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user