devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Consolidated buy and sell functions of Smith, Witch and Healer

Open joewis opened this issue 4 years ago • 5 comments

Introducing S_Scroll, S_StartBuy, S_BuyEnter, S_BuItem function and switch between the respective Item Arrays rather than duplicating the functions for each store. Removed the duplicate functions. Wirt is not included as his item is not stored in an array (yet).

This approach works for sell functionality as well, I leave that for a separate commit.

joewis avatar Apr 14 '21 09:04 joewis

Submitted for sell functions. I'll apply clang-format at the end - it appears to cause lots of whitespace changes.

joewis avatar Apr 15 '21 00:04 joewis

@joewis Please only apply clang-format to change lines btw

glebm avatar Apr 15 '21 04:04 glebm

Patching Wirt into the same store logic proves more tricky than expected, of all reasons, because the item in the buy dialogue is offset by 1 item. I leave him be for now.

joewis avatar Apr 15 '21 05:04 joewis

@obligaron I fixed some issues when rebasing and cleaned up some related code with how stores are refreshed. I actually think it fixes a vanilla bug where after drinking enough exiles to use an item it would still appear as red in the store, but haven't confirmed if that was the case.

I may have introduced some new issues related to the line number logic since stextsel = would be 14/16/18 for different stores that visually appears the same. I don't quite understand why and I think it doesn't really matter as that part should just be discarded in the next rewrite of this code.

I'll try and also get the boy shop merged with the other vendors so that it's all combined.

AJenbo avatar Dec 12 '21 02:12 AJenbo

Adding to the list: Cain now crashes with segfault when attempting to identify items.

joewis avatar Dec 13 '21 09:12 joewis