MakeCraftedItem Fix in AbstractCraftingSkill.cs

A place to submit .patch fixes for the DOL SVN

Moderator: Developer Team

MakeCraftedItem Fix in AbstractCraftingSkill.cs

Postby Maze » Sun Feb 23, 2014 5:57 pm

Sorry, I'm not uploading the entire patch because I've made a lot of changes to the file that I don't want to submit until they've been fully researched / implemented neatly.

However, I'm submitting this because of a critical error that's caused by attempting to craft anything while any Unique Item without a "#" in the id in in the bag while crafting. This is problematic with the RoG script from Storm. I would imagine that unless things are implemented differently there, this problem exists there. Basically, the craft code attempts to extract the id_nb from a unique item by finding where the "#" occurs. When it does this, it uses the length of the string up to that point. If there's no "#" the length returns a -1, causes an exception, and the result is nothing can be crafted.

So, this:

in AbstractCraftingSkill.cs
Code: Select all
if (item.Template is ItemUnique) { string itemid = item.Id_nb.Substring(0, item.Id_nb.LastIndexOf('#')); if (itemid.Equals(itemToCraft.Id_nb) == false) continue; }
should be changed to this
Code: Select all
if (item.Template is ItemUnique) { if (item.Id_nb.Contains("#") == false) continue; string itemid = item.Id_nb.Substring(0, item.Id_nb.LastIndexOf('#')); if (itemid.Equals(itemToCraft.Id_nb) == false) continue; }
Last edited by Maze on Sun Feb 23, 2014 6:43 pm, edited 2 times in total.
User avatar
Maze
DOL Apprentice
 
Posts: 38
Joined: Wed Aug 08, 2012 3:39 am

Re: MakeCraftedItem Fix in AbstractCraftingSkill.cs

Postby Tolakram » Sun Feb 23, 2014 6:24 pm

When would someone be using a unique item in crafting? I guess I'm asking, when would this occur in game? How can someone reproduce this?
Code: Select all
itemid.Equals(itemToCraft.Id_nb) == false
Are you a programmer? Nice to see someone using == false instead of the easily missed ! :)

Unfortunately I don't get the Equals() usage here. itemid != itemToCraft.Id_nb seems a lot more readable.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: MakeCraftedItem Fix in AbstractCraftingSkill.cs

Postby Maze » Sun Feb 23, 2014 6:27 pm

That's just how it was written originally.

Unique items are always made in crafting since they're unique by definition. Reproduce by having any unique item in your bag without # in the id and trying to craft something.

One example of a unique item that would cause this is any item created by the RoG script.
User avatar
Maze
DOL Apprentice
 
Posts: 38
Joined: Wed Aug 08, 2012 3:39 am

Re: MakeCraftedItem Fix in AbstractCraftingSkill.cs

Postby Tolakram » Mon Feb 24, 2014 12:09 am

Not sure what core version you are using but the code above is not in AbstractCraftingSkill or any other crafting file in the current core version.

I really appreciate you trying to help but I wonder if you are working off an already modified core, or an older version.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: MakeCraftedItem Fix in AbstractCraftingSkill.cs

Postby Maze » Mon Feb 24, 2014 2:34 am

Okay, I was working with a core that was mostly unmodified but it looks like there were a few changes. Seems it was modified to fix stacking (stuff like trinkets weren't stacking automatically which is an annoyance)

I had done some fixes to the subskill caps (more on that later), but it looks like someone else had already done some fix for stacking. Inherited code :(

Anyways, here's the code

Change this:
Code: Select all
if (item.Id_nb.Equals(itemToCraft.Id_nb) == false) continue;
To this:
Code: Select all
if (item.Template is ItemUnique && item.Id_nb.Contains("#")) { string itemid = item.Id_nb.Substring(0, item.Id_nb.LastIndexOf('#')); if (itemid != itemToCraft.Id_nb) continue; } else if (item.Id_nb != itemToCraft.Id_nb) { continue; }
This will make stackable crafted items stack.

The error before wasn't in the core, but this still fixes an issue in the core with stacking.
User avatar
Maze
DOL Apprentice
 
Posts: 38
Joined: Wed Aug 08, 2012 3:39 am

Re: MakeCraftedItem Fix in AbstractCraftingSkill.cs

Postby Tolakram » Mon Feb 24, 2014 12:42 pm

I'll have to look at that when I get time, thanks.

My solution, done way back on May 27th, 2011, was to be able to designate certain crafted items as templated items instead.

- Added: CraftedItems can now be designated to make templated items instead of uniques. This can be used to make items where quality does not matter and stacking is desired.

This requires a DB change but avoids doing any funky checks when looking at id_nb.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA


Return to “%s” DOL Code Contributions

Who is online

Users browsing this forum: No registered users and 1 guest