Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Inventory Refactor #1197

Merged
merged 72 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
bdfb0c2
HandleActionStackableSplitTo3D cleanup
Mag-nus Dec 14, 2018
9d3eb28
Container: Remove duplicate TryRemoveFromInventoryWithoutClear()
Mag-nus Dec 15, 2018
bf734bc
Always fix placement positions in Container SortWorldObjectsIntoInven…
Mag-nus Dec 15, 2018
18c376e
HandleActionStackableSplitToContainer cleanup
Mag-nus Dec 15, 2018
5b3eff0
Inventory cleanup
Mag-nus Dec 15, 2018
ebd9ee4
Cleanup child object management (items held in hands)
Mag-nus Dec 15, 2018
da1244c
More player inventory progress
Mag-nus Dec 17, 2018
835b062
Remove ActionChain.AddDelayTicks() (not used, we use time based)
Mag-nus Dec 17, 2018
fe69cc7
Fix opcode log warning in InboundMessageManager
Mag-nus Dec 17, 2018
785bb70
HandleActionDropItem looking good on the new system
Mag-nus Dec 17, 2018
0cde173
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 17, 2018
978bae3
HandleActionDropItem comments
Mag-nus Dec 17, 2018
6db30e6
Fix PlayerEnterWorld exception when player has null Location
Mag-nus Dec 18, 2018
6b3087c
More inventory progress
Mag-nus Dec 19, 2018
7a5b4ec
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 19, 2018
b6ce92f
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 21, 2018
bf097d4
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 22, 2018
ee0064b
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 24, 2018
a59080e
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 26, 2018
249a03d
minor cleanups
Mag-nus Dec 26, 2018
176e2ef
Remove IComparable from WorldObject
Mag-nus Dec 26, 2018
ef6837c
Inventory Progress
Mag-nus Dec 27, 2018
8126548
Fix stack size bug in Developer commands that use AddWeeniesToInventory
Mag-nus Dec 27, 2018
2a7585b
more inventory progress
Mag-nus Dec 28, 2018
69c887d
More split progress
Mag-nus Dec 28, 2018
013c147
more stack progress
Mag-nus Dec 28, 2018
4fc2c7e
Use virtual MotionPickup
Mag-nus Dec 28, 2018
0696573
Inventory improvements
Mag-nus Dec 28, 2018
d15c187
more inventory progress
Mag-nus Dec 28, 2018
f619519
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 28, 2018
d58df94
player/npc give refactored
Mag-nus Dec 29, 2018
3e88c48
Convert some obsolete inventory functions over to TryConsumeFromInven…
Mag-nus Dec 29, 2018
61e1484
All inventory functions converted
Mag-nus Dec 29, 2018
5ceb456
Fix item decaying explosions
Mag-nus Dec 29, 2018
32e97c6
Fix player trade
Mag-nus Dec 29, 2018
5081ea6
More fixes
Mag-nus Dec 29, 2018
07877cf
Fix giving partial stacks
Mag-nus Dec 29, 2018
4e3aede
Fix burden limitations when picking up items
Mag-nus Dec 29, 2018
ef6e2d6
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 29, 2018
a38888e
Fix selling items
Mag-nus Dec 29, 2018
8b5a48e
Inventory move to fixes
Mag-nus Dec 29, 2018
866b431
Cleanup TrySetChild
Mag-nus Dec 29, 2018
8a959d2
Don't decay IsStuck objects
Mag-nus Dec 29, 2018
5dfb356
Don't allow pickup of IsStuck items
Mag-nus Dec 29, 2018
0812222
Fix moving equipped items around
Mag-nus Dec 29, 2018
bd1670d
Weapons now work
Mag-nus Dec 30, 2018
436d7ed
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 30, 2018
d39e034
Fix player location null restore
Mag-nus Dec 30, 2018
5f5ef6c
Add back HeritageBonuses to Player_Skills
Mag-nus Dec 30, 2018
09e0620
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 30, 2018
7ed2b11
Fix equipment spell/dispell on equip/dequip
Mag-nus Dec 30, 2018
d632b4d
Fix non-selectable wielded items from showing on the player model
Mag-nus Dec 30, 2018
5e6f73a
Fix wield/unwield sound for equipped items that aren't childeren
Mag-nus Dec 30, 2018
6c62155
TrySetChild should ClearChild if it's not a valid child.
Mag-nus Dec 30, 2018
d0a74c6
Fix missile ammo as child
Mag-nus Dec 30, 2018
e323c2f
Send DeleteObject instead of PickupEvent on Dequip. This fixes disapp…
Mag-nus Dec 30, 2018
9df9c5d
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 30, 2018
e4a156a
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 31, 2018
7d00e3f
Couple notes where item recovieres should go
Mag-nus Dec 31, 2018
7ef7522
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Dec 31, 2018
85e41c4
Hopefully this fixes the ammo being displayed incorrectly
Mag-nus Jan 1, 2019
cd4e861
Couple inventory fixes
Mag-nus Jan 1, 2019
7869eb4
Allow close container that has no viewer
Mag-nus Jan 1, 2019
9e3e7bf
Couple more log warnings for potential lost items
Mag-nus Jan 1, 2019
661222b
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Jan 1, 2019
9ec0e21
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Jan 2, 2019
62b2b0d
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Jan 2, 2019
396b79e
Attuned check removed for GiveObjecttoNPC
Mag-nus Jan 3, 2019
da0384c
Don't consume unlimited use gems
Mag-nus Jan 3, 2019
b761d0d
Merge remote-tracking branch 'upstream/master' into MoreInventoryWork
Mag-nus Jan 3, 2019
7bb7ce0
Fix HandleDestroyBonded
Mag-nus Jan 3, 2019
a3a6cdf
Fix destroying equipped items when consumed
Mag-nus Jan 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/ACE.Server/Command/Handlers/AdminCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,7 @@ public static void HandleMorph(Session session, params string[] parameters)
worldObject.PaletteTemplate = wearable.Palette;
if (wearable.Shade > 0)
worldObject.Shade = wearable.Shade;
player.TryEquipObject(worldObject, worldObject.GetProperty(PropertyInt.ValidLocations) ?? 0);
player.TryEquipObjectWithNetworking(worldObject, worldObject.GetProperty(PropertyInt.ValidLocations) ?? 0);
}

var containables = weenie.WeeniePropertiesCreateList.Where(x => x.DestinationType == (int)DestinationType.Contain || x.DestinationType == (int)DestinationType.Shop
Expand Down
13 changes: 6 additions & 7 deletions Source/ACE.Server/Command/Handlers/DeveloperCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -912,14 +912,13 @@ private static void AddWeeniesToInventory(Session session, HashSet<uint> weenieI
if (loot == null) // weenie doesn't exist
continue;

if (stackSize == null)
stackSize = loot.MaxStackSize;
var stackSizeForThisWeenieId = stackSize ?? loot.MaxStackSize;

if (stackSize > 1)
if (stackSizeForThisWeenieId > 1)
{
loot.StackSize = stackSize;
loot.EncumbranceVal = (loot.StackUnitEncumbrance ?? 0) * (stackSize ?? 1);
loot.Value = (loot.StackUnitValue ?? 0) * (stackSize ?? 1);
loot.StackSize = stackSizeForThisWeenieId;
loot.EncumbranceVal = (loot.StackUnitEncumbrance ?? 0) * (stackSizeForThisWeenieId ?? 1);
loot.Value = (loot.StackUnitValue ?? 0) * (stackSizeForThisWeenieId ?? 1);
}

session.Player.TryCreateInInventoryWithNetworking(loot);
Expand All @@ -929,7 +928,7 @@ private static void AddWeeniesToInventory(Session session, HashSet<uint> weenieI
[CommandHandler("weapons", AccessLevel.Developer, CommandHandlerFlag.RequiresWorld, 0, "Creates testing items in your inventory.")]
public static void HandleWeapons(Session session, params string[] parameters)
{
HashSet<uint> weenieIds = new HashSet<uint> { 93, 127, 130, 148, 300, 307, 311, 326, 338, 348, 350, 7765, 12748, 12463, 31812 };
HashSet<uint> weenieIds = new HashSet<uint> { 93, 148, 300, 307, 311, 326, 338, 348, 350, 7765, 12748, 12463, 31812 };

AddWeeniesToInventory(session, weenieIds);
}
Expand Down
13 changes: 0 additions & 13 deletions Source/ACE.Server/Entity/Actions/ActionChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,6 @@ public ActionChain AddDelaySeconds(double timeInSeconds)
return this;
}

public ActionChain AddDelayTicks(double timeInTicks)
{
if (Double.IsNaN(timeInTicks))
{
Console.WriteLine("WARNING: ActionChain.AddDelayTicks(" + timeInTicks + ")");
return this;
}

AddAction(WorldManager.DelayManager, new DelayAction(timeInTicks));

return this;
}

public void EnqueueChain()
{
if (FirstElement != null)
Expand Down
2 changes: 1 addition & 1 deletion Source/ACE.Server/Entity/AttackDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AttackDamage(WorldObject source, uint amount, bool criticalHit)
/// <param name="source">The attacker to add up the damage for</param>
public static ulong GetTotalDamage(List<AttackDamage> attacks, WorldObject source)
{
return (ulong)attacks.Where(a => a.Source.Equals(source)).Sum(a => a.Amount);
return (ulong)attacks.Where(a => a.Source == source).Sum(a => a.Amount);
}

/// <summary>
Expand Down
50 changes: 13 additions & 37 deletions Source/ACE.Server/Entity/Landblock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using ACE.DatLoader;
using ACE.DatLoader.FileTypes;
using ACE.Entity;
using ACE.Entity.Enum;
using ACE.Entity.Enum.Properties;
using ACE.Server.Entity.Actions;
using ACE.Server.Factories;
Expand Down Expand Up @@ -365,9 +366,9 @@ private void AddWorldObjectInternal(WorldObject wo)
wo.NotifyPlayers();
}

public void RemoveWorldObject(ObjectGuid objectId, bool adjacencyMove = false)
public void RemoveWorldObject(ObjectGuid objectId, bool adjacencyMove = false, bool fromPickup = false)
{
RemoveWorldObjectInternal(objectId, adjacencyMove);
RemoveWorldObjectInternal(objectId, adjacencyMove, fromPickup);
}

/// <summary>
Expand All @@ -380,37 +381,7 @@ public void RemoveWorldObjectForPhysics(ObjectGuid objectId, bool adjacencyMove
RemoveWorldObjectInternal(objectId, adjacencyMove);
}

/// <summary>
/// This will also set the item.Location to null.
/// </summary>
public bool RemoveWorldObjectFromPickup(ObjectGuid objectGuid)
{
// Find owner of wo
var lb = GetOwner(objectGuid);

if (lb == null)
{
log.Error("Landblock QueueItemRemove failed to GetOwner");
return false;
}

var item = GetObject(objectGuid);

if (item == null)
{
log.Error("Landblock QueueItemRemove failed to GetObject");
return false;
}

RemoveWorldObjectInternal(objectGuid, true);
//item.PhysicsObj.DestroyObject(); // destroy physicsobj, but do not remove from tracking

item.Location = null;

return true;
}

private void RemoveWorldObjectInternal(ObjectGuid objectId, bool adjacencyMove = false)
private void RemoveWorldObjectInternal(ObjectGuid objectId, bool adjacencyMove = false, bool fromPickup = false)
{
//log.Debug($"LB {Id.Landblock:X}: removing {objectId.Full:X}");

Expand All @@ -427,7 +398,7 @@ private void RemoveWorldObjectInternal(ObjectGuid objectId, bool adjacencyMove =
if (!adjacencyMove)
{
// really remove it - send message to client to remove object
wo.EnqueueActionBroadcast((Player p) => p.RemoveTrackedObject(wo, true));
wo.EnqueueActionBroadcast(p => p.RemoveTrackedObject(wo, fromPickup));

wo.PhysicsObj.DestroyObject();
}
Expand Down Expand Up @@ -502,12 +473,17 @@ public WorldObject GetObject(ObjectGuid guid)
public WorldObject GetWieldedObject(ObjectGuid guid, bool searchAdjacents = true)
{
// search creature wielded items in current landblock
var creatures = worldObjects.Values.Where(wo => wo is Creature);
var creatures = worldObjects.Values.OfType<Creature>();
foreach (var creature in creatures)
{
var wieldedItem = ((Creature)creature).GetWieldedItem(guid);
var wieldedItem = creature.GetEquippedItem(guid);
if (wieldedItem != null)
return wieldedItem; // found it
{
if ((wieldedItem.CurrentWieldedLocation & EquipMask.Selectable) != 0)
return wieldedItem;

return null;
}
}

// try searching adjacent landblocks if not found
Expand Down
9 changes: 7 additions & 2 deletions Source/ACE.Server/Managers/EmoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,12 @@ public void ExecuteEmote(BiotaPropertiesEmote emoteSet, BiotaPropertiesEmoteActi

case EmoteType.DeleteSelf:

WorldObject.Destroy();
var destroyChain = new ActionChain();
destroyChain.AddAction(WorldObject, () => WorldObject.ApplyVisualEffects(PlayScript.Destroy));
destroyChain.AddDelaySeconds(3);
destroyChain.AddAction(WorldObject, () => WorldObject.Destroy());
destroyChain.EnqueueChain();

break;

case EmoteType.DirectBroadcast:
Expand Down Expand Up @@ -893,7 +898,7 @@ public void ExecuteEmote(BiotaPropertiesEmote emoteSet, BiotaPropertiesEmoteActi
item = WorldObjectFactory.CreateNewWorldObject((uint)emote.WeenieClassId);
if (item == null) break;

success = player.TryRemoveItemFromInventoryWithNetworkingWithDestroy(item, (ushort)emote.Amount);
success = player.TryConsumeFromInventoryWithNetworking(item, emote.Amount ?? 0);
}
break;

Expand Down
2 changes: 1 addition & 1 deletion Source/ACE.Server/Managers/EmoteManagerExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public void Execute(Emote emote, WorldObject target)
item = WorldObjectFactory.CreateNewWorldObject(wcid);
if (item == null) break;

var success = player.TryRemoveItemFromInventoryWithNetworkingWithDestroy(item, (ushort)emote.Amount);
var success = player.TryConsumeFromInventoryWithNetworking(item, (int)emote.Amount);
}
break;

Expand Down
6 changes: 4 additions & 2 deletions Source/ACE.Server/Managers/RecipeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -769,13 +769,15 @@ public static void DestroyItem(Player player, Recipe recipe, WorldObject item, u
{
if (item.OwnerId == player.Guid.Full || player.GetInventoryItem(item.Guid) != null)
{
if (!player.TryRemoveItemFromInventoryWithNetworkingWithDestroy(item, (ushort)amount))
if (!player.TryConsumeFromInventoryWithNetworking(item, (int)amount))
log.Warn($"RecipeManager.DestroyItem({player.Name}, {item.Name}, {amount}, {msg}): failed to remove {item.Name}");
}
else if (item.WielderId == player.Guid.Full)
{
if (!player.TryRemoveItemWithNetworking(item))
if (!player.TryDequipObjectWithNetworking(item.Guid, out _, Player.DequipObjectAction.ConsumeItem))
log.Warn($"RecipeManager.DestroyItem({player.Name}, {item.Name}, {amount}, {msg}): failed to remove {item.Name}");
else
item.Destroy();
}
else
{
Expand Down
10 changes: 10 additions & 0 deletions Source/ACE.Server/Managers/WorldManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -301,6 +302,15 @@ private static void DoPlayerEnterWorld(Session session, Character character, Bio

session.SetPlayer(player);

// If the client is missing a location, we start them off in the starter dungeon
if (session.Player.Location == null)
{
if (session.Player.Instantiation != null)
session.Player.Location = new Position(session.Player.Instantiation);
else
session.Player.Location = new Position(2349072813, 12.3199f, -28.482f, 0.0049999995f, 0.0f, 0.0f, -0.9408059f, -0.3389459f);
}

session.Player.PlayerEnterWorld();

if (character.TotalLogins <= 1 || PropertyManager.GetBool("alwaysshowwelcome").Item)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ACE.Entity;

namespace ACE.Server.Network.GameAction.Actions
{
public static class GameActionGiveObjectRequest
Expand All @@ -8,7 +9,7 @@ public static void Handle(ClientMessage message, Session session)
{
uint targetID = message.Payload.ReadUInt32();
uint objectID = message.Payload.ReadUInt32();
uint amount = message.Payload.ReadUInt32();
int amount = message.Payload.ReadInt32();
ObjectGuid targetGuid = new ObjectGuid(targetID);
ObjectGuid objectGuid = new ObjectGuid(objectID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void Handle(ClientMessage message, Session session)
{
// Read in the applicable data.
uint stackId = message.Payload.ReadUInt32();
uint amount = message.Payload.ReadUInt32();
int amount = message.Payload.ReadInt32();

session.Player.HandleActionStackableSplitTo3D(stackId, amount);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/ACE.Server/Network/GameEvent/GameEventMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected GameEventMessage(GameEventType eventType, GameMessageGroup group, Sess
Session = session;

Writer.WriteGuid(session.Player.Guid);
var debugMessage = $"GameEventSequence Update - {eventType} - GameEventSequence was {session.GameEventSequence}";
//var debugMessage = $"GameEventSequence Update - {eventType} - GameEventSequence was {session.GameEventSequence}";
Writer.Write(session.GameEventSequence++);
//Console.WriteLine(debugMessage + $" and is now {session.GameEventSequence}");
Writer.Write((uint)EventType);
Expand Down
4 changes: 2 additions & 2 deletions Source/ACE.Server/Network/Managers/InboundMessageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void HandleClientMessage(ClientMessage message, Session session)
}
else
{
log.Warn($"Received unhandled fragment opcode: 0x{(uint)opcode:X}");
log.Warn($"Received unhandled fragment opcode: 0x{(int)opcode:X4} - {opcode}");
}
}

Expand All @@ -121,7 +121,7 @@ public static void HandleGameAction(GameActionType opcode, ClientMessage message
}
else
{
log.Warn($"Received unhandled GameActionType: 0x{(uint)opcode:X}");
log.Warn($"Received unhandled GameActionType: 0x{(int)opcode:X4} - {opcode}");
}
}
}
Expand Down
Loading