Merge branch 'general-devel' of github.com:NyxStudios/TShock into general-devel
Conflicts: CHANGELOG.md
This commit is contained in:
commit
58224e4440
3 changed files with 34 additions and 3 deletions
|
|
@ -77,7 +77,20 @@ namespace TShockAPI.DB
|
||||||
playerData.maxHealth = reader.Get<int>("MaxHealth");
|
playerData.maxHealth = reader.Get<int>("MaxHealth");
|
||||||
playerData.mana = reader.Get<int>("Mana");
|
playerData.mana = reader.Get<int>("Mana");
|
||||||
playerData.maxMana = reader.Get<int>("MaxMana");
|
playerData.maxMana = reader.Get<int>("MaxMana");
|
||||||
playerData.inventory = reader.Get<string>("Inventory").Split('~').Select(NetItem.Parse).ToArray();
|
List<NetItem> inventory = reader.Get<string>("Inventory").Split('~').Select(NetItem.Parse).ToList();
|
||||||
|
if (inventory.Count < NetItem.MaxInventory)
|
||||||
|
{
|
||||||
|
//TODO: unhardcode this - stop using magic numbers and use NetItem numbers
|
||||||
|
//Set new armour slots empty
|
||||||
|
inventory.InsertRange(67, new NetItem[2]);
|
||||||
|
//Set new vanity slots empty
|
||||||
|
inventory.InsertRange(77, new NetItem[2]);
|
||||||
|
//Set new dye slots empty
|
||||||
|
inventory.InsertRange(87, new NetItem[2]);
|
||||||
|
//Set the rest of the new slots empty
|
||||||
|
inventory.AddRange(new NetItem[NetItem.MaxInventory - inventory.Count]);
|
||||||
|
}
|
||||||
|
playerData.inventory = inventory.ToArray();
|
||||||
playerData.spawnX = reader.Get<int>("spawnX");
|
playerData.spawnX = reader.Get<int>("spawnX");
|
||||||
playerData.spawnY = reader.Get<int>("spawnY");
|
playerData.spawnY = reader.Get<int>("spawnY");
|
||||||
playerData.hair = reader.Get<int?>("hair");
|
playerData.hair = reader.Get<int?>("hair");
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace TShockAPI
|
||||||
public static readonly int SafeSlots = PiggySlots;
|
public static readonly int SafeSlots = PiggySlots;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 59 - The size of the player's inventory (inventory, coins, ammo)
|
/// 59 - The size of the player's inventory (inventory, coins, ammo, held item)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly int InventorySlots = 59;
|
public static readonly int InventorySlots = 59;
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace TShockAPI
|
||||||
public static readonly int MiscDyeSlots = MiscEquipSlots;
|
public static readonly int MiscDyeSlots = MiscEquipSlots;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 179 - The inventory size (including armour, dies, coins, ammo, piggy, safe, and trash)
|
/// 180 - The inventory size (inventory, held item, armour, dies, coins, ammo, piggy, safe, and trash)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly int MaxInventory = InventorySlots + ArmorSlots + DyeSlots + MiscEquipSlots + MiscDyeSlots + PiggySlots + SafeSlots + 1;
|
public static readonly int MaxInventory = InventorySlots + ArmorSlots + DyeSlots + MiscEquipSlots + MiscDyeSlots + PiggySlots + SafeSlots + 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1112,6 +1112,13 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores an item at the specific storage slot
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slot"></param>
|
||||||
|
/// <param name="netID"></param>
|
||||||
|
/// <param name="prefix"></param>
|
||||||
|
/// <param name="stack"></param>
|
||||||
public void StoreSlot(int slot, int netID, byte prefix, int stack)
|
public void StoreSlot(int slot, int netID, byte prefix, int stack)
|
||||||
{
|
{
|
||||||
if (slot > (this.inventory.Length - 1)) //if the slot is out of range then dont save
|
if (slot > (this.inventory.Length - 1)) //if the slot is out of range then dont save
|
||||||
|
|
@ -1122,6 +1129,10 @@ namespace TShockAPI
|
||||||
this.inventory[slot] = new NetItem(netID, stack, prefix);
|
this.inventory[slot] = new NetItem(netID, stack, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies a characters data to this object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="player"></param>
|
||||||
public void CopyCharacter(TSPlayer player)
|
public void CopyCharacter(TSPlayer player)
|
||||||
{
|
{
|
||||||
this.health = player.TPlayer.statLife > 0 ? player.TPlayer.statLife : 1;
|
this.health = player.TPlayer.statLife > 0 ? player.TPlayer.statLife : 1;
|
||||||
|
|
@ -1198,6 +1209,7 @@ namespace TShockAPI
|
||||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
||||||
NetItem.MiscDyeSlots + NetItem.PiggySlots)
|
NetItem.MiscDyeSlots + NetItem.PiggySlots)
|
||||||
{
|
{
|
||||||
|
//98-138
|
||||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
||||||
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots);
|
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots);
|
||||||
this.inventory[i] = (NetItem)piggy[index];
|
this.inventory[i] = (NetItem)piggy[index];
|
||||||
|
|
@ -1206,17 +1218,23 @@ namespace TShockAPI
|
||||||
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots + NetItem.MiscEquipSlots +
|
||||||
NetItem.MiscDyeSlots + NetItem.PiggySlots + NetItem.SafeSlots)
|
NetItem.MiscDyeSlots + NetItem.PiggySlots + NetItem.SafeSlots)
|
||||||
{
|
{
|
||||||
|
//138-178
|
||||||
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
var index = i - (NetItem.InventorySlots + NetItem.ArmorSlots + NetItem.DyeSlots
|
||||||
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots);
|
+ NetItem.MiscEquipSlots + NetItem.MiscDyeSlots + NetItem.PiggySlots);
|
||||||
this.inventory[i] = (NetItem)safe[index];
|
this.inventory[i] = (NetItem)safe[index];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//179
|
||||||
this.inventory[i] = (NetItem)trash;
|
this.inventory[i] = (NetItem)trash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Restores a player's character to the state stored in the database
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="player"></param>
|
||||||
public void RestoreCharacter(TSPlayer player)
|
public void RestoreCharacter(TSPlayer player)
|
||||||
{
|
{
|
||||||
// Start ignoring SSC-related packets! This is critical so that we don't send or receive dirty data!
|
// Start ignoring SSC-related packets! This is critical so that we don't send or receive dirty data!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue