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

Update to use Action Queue - Requested Changes Made 4/14/2017 #229

Merged
merged 11 commits into from
Apr 18, 2017

Conversation

ogmage78
Copy link
Contributor

Can someone with more experience with Action Queue take a look at the file Landblock and the case GameActionType.DropItem: I don't want to refactor all of my stuff until someone can tell me if this looks correct. It complies and works fine. I would just like a sanity check.

Copy link
Contributor

@Mogwai-TheFurry Mogwai-TheFurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, Whitespace whitespace whitespace. And changelog.

using global::ACE.Entity.Enum.Properties;
using global::ACE.Network.Sequence;

using static LandblockManager;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???? This makes for non-obvious inline code. Please no.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making sure I understand the issue. It looks like I must have added something in landblock that pulled in a reference to landblockmanager. That is the issue right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used some automatic tool that did the "using static" stuff which is new in .Net 6 and that quite frankly, I absolutely think is a bad thing they did. It's akin to VB6's "with" statement, only scoped to the entire file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not even notice it. Thanks and I will clean that up - along with the other items.

@@ -19,6 +19,11 @@

namespace ACE.Entity
{
using global::ACE.Entity.Enum.Properties;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move above namespace please.

{
Player aPlayer = null;
WorldObject inventoryItem = null;
lock (objectCacheLocker)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know, I don't think you actually need to lock up the landblock's mutex here. You're not modifying the object collection in this code block.

}

// We are droping the item - let's keep track of change in burden

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the item from the player's inventory should do all this, not the landblock.


// TODO: I need to look at the PCAPS to see the delta in position from the dropper and the item dropped. Temp position.

inventoryItem.PositionFlag = UpdatePositionFlag.Contact
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modification of the inventoryItem's position/whatever data should stay here in the landblock, yes.

@@ -51,7 +51,7 @@ public virtual Position Location

public WeenieHeaderFlag2 WeenieFlags2 { get; protected set; }

public UpdatePositionFlag PositionFlag { get; protected set; } = UpdatePositionFlag.Contact;
public UpdatePositionFlag PositionFlag { get; set; } = UpdatePositionFlag.Contact;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um.... Not a huge fan of this. This isn't the way to solve the always-falling-other-players bug.

{
lock (this.inventoryMutex)
lock (inventoryMutex)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also modify burden here

}
}

public void RemoveFromInventory(ObjectGuid objectGuid)
public virtual void RemoveFromInventory(ObjectGuid inventoryItemGuid)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also modify burden here

@ogmage78 ogmage78 changed the title Work in progress Action Queue - Not for merging Update to use Action Queue - Complete Ready for review and Merge Apr 13, 2017
@ogmage78
Copy link
Contributor Author

Updated and ready for merge upon approval.

Copy link
Contributor

@Mogwai-TheFurry Mogwai-TheFurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace stuff. quick fixes

{
lock (inventoryMutex)
{
if (inventory.ContainsKey(objectGuid))
inventory.Remove(objectGuid);
if (!inventory.ContainsKey(inventoryItem.Guid)) inventory.Add(inventoryItem.Guid, inventoryItem);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace - logic on different line than condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok got rid of inline if's, think I fixed the whitespace - I may need remedial training on that to make sure I understand our style. I fixed my last bug and think it is all ready to go.

{
if (!this.inventory.ContainsKey(obj.Guid))
this.inventory.Add(obj.Guid, obj);
if (!this.inventory.ContainsKey(inventoryItemGuid)) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before. no inline ifs.

… I may need a remedical lesson on how to format this correctly. :)
if (worldObjects.ContainsKey(playerId))
{
aPlayer = (Player)worldObjects[playerId];
inventoryItem = worldObjects[inventoryId];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't assume inventoryId is in this landblock. We need something like FindWorldObject which walks this and adjacent landblocks to find it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. We were chatting about it in Discord - was going to address that later as it is such an edge case. I would have to try to pickup something someone had dropped across a landblock boundary. At the moment all it should do is fail to pick it up. I can refactor to use the FindWorldObject later if that is ok? Thanks

@ogmage78
Copy link
Contributor Author

Stackoverflow pointed out a part of code that was not checking for existence prior to usage - I made that fix.

@ogmage78 ogmage78 changed the title Update to use Action Queue - Complete Ready for review and Merge Update to use Action Queue - Requested Changes Made 4/14/2017 Apr 14, 2017
@Mogwai-TheFurry Mogwai-TheFurry merged commit 29a2721 into ACEmulator:master Apr 18, 2017
@ogmage78 ogmage78 deleted the invpart3 branch April 23, 2017 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants