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

Add HasUst check to Salvaging #4172

Merged
merged 3 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public static class GameActionCreateTinkeringTool
[GameAction(GameActionType.CreateTinkeringTool)]
public static void Handle(ClientMessage message, Session session)
{
var vendorGuid = message.Payload.ReadUInt32();
var toolGuid = message.Payload.ReadUInt32();
uint itemcount = message.Payload.ReadUInt32();

var items = new List<uint>();
Expand All @@ -18,7 +18,7 @@ public static void Handle(ClientMessage message, Session session)
items.Add(message.Payload.ReadUInt32());
}

session.Player.HandleSalvaging(items);
session.Player.HandleSalvaging(toolGuid, items);
}
}
}
24 changes: 22 additions & 2 deletions Source/ACE.Server/WorldObjects/Player_Crafting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;

using ACE.Common.Extensions;
using ACE.Entity.Enum;
using ACE.Entity.Enum.Properties;
using ACE.Server.Entity;
Expand Down Expand Up @@ -122,8 +121,29 @@ public CreatureSkill GetMaxSkill(List<Skill> skills)
Skill.MagicItemTinkering
};

public void HandleSalvaging(List<uint> salvageItems)
private bool ToolIsValidUst(uint tool)
{
var toolObject = FindObject(tool, SearchLocations.Everywhere, out _, out var rootOwner, out _);

if (toolObject == null || toolObject.WeenieClassId != (uint)ACE.Entity.Enum.WeenieClassName.W_TINKERINGTOOL_CLASS)
{
SendWeenieError(WeenieError.NotASalvageTool);
return false;
}
else if (rootOwner != this)
{
SendWeenieError(WeenieError.YouDoNotOwnThatSalvageTool);
return false;
}
else
return true;
}

public void HandleSalvaging(uint tool, List<uint> salvageItems)
{
if (!ToolIsValidUst(tool))
return;

var salvageBags = new List<WorldObject>();
var salvageResults = new SalvageResults();

Expand Down