Commit Graph
560 Commits
Author SHA1 Message Date
ephphatha 4d7c08d5b4 Deduplicate code for setting stat requirements/flag 2022-04-21 05:44:38 +02:00
ephphatha 64a2c41b2c Set clang-tidy config for MethodCase option
Previously this was falling back to FunctionCase, leading to inconsistent casing of class methods throughout the codebase. Applied to Item as an example.
2022-04-20 13:50:57 +02:00
ephphatha 7a3722d63b Add helper for clearing an item and using it's old value
Used when moving from one persistent variable to another where we want the source variable to be marked empty. Defining as a function instead of move constructor/assignment operator as we only really need to mark the source for xvalues. Detecting that in the constructor/assignment would be needlessly complicated.
2022-04-20 13:35:55 +02:00
Andrew James 72cfdc31ea Clear held item when putting in an empty belt slot (#4490) 2022-04-19 07:00:33 +01:00
ephphatha ad7ad46ce9 Explicitly clear HoldItem when putting an item into the Inventory/Stash
Previously this also relied on NewCursor modifying MyPlayer->HoldItem when setting the cursor to a non-item cursor to avoid item duplication, seems more appropriate to make this explicit in the caller.
2022-04-18 19:25:55 +02:00
ephphatha 7e7798fd2b Add function to mark an item as empty 2022-04-18 19:25:55 +02:00
ephphatha 28b6eaf7de Only use HoldItem in InvGetItem if necessary
When auto-placing gold in the inventory there's no need to trample HoldItem.
2022-04-18 17:41:01 +02:00
ephphatha 026b428c7d Add NewCursor(Item&) for setting the cursor based on a held item
The case for empty items should never be hit in the current code, but I've got a related PR that'll make use of that so adding it now.
2022-04-18 16:59:34 +02:00
Anders Jenbo dc706e8ed5 Use HoldItem for determining if an item is held
This cleans up a bit of code and solves a few edge cases where an item
could be lost, the game be unresponsive, or miss fire an event during
lag cause of the cursor not reflecting the currently held item.
2022-04-18 11:27:07 +02:00
ephphatha 5b83f2a7c4 Remove SetICursor and unused globals 2022-04-16 05:54:03 +02:00
ephphatha aab970dcde Use GetIventorySize(Item) instead of SetICursor in inv.cpp
Also use mod for testing if item dimensions are even. Lets assume the release build can optimise this into a bitmask, probably wont need to do this anyway after a refactor.
2022-04-15 09:43:15 +02:00
Gleb Mazovetskiy a66ca44695 Zero-based frame indexing
Index frames starting at 0 instead of 1.
2022-04-14 04:39:26 +01:00
Anders Jenbo c5a3d138e0 Avoid using HeldItem in CheckInvSwap 2022-04-14 01:20:06 +02:00
staphen 33b27f630f Clean up logic for 1-handed weapons in CheckInvPaste() 2022-04-14 01:19:14 +02:00
staphen d16c2f0086 Avoid recreating items in PutItem locally 2022-04-10 23:37:33 +02:00
staphen cf41911417 Use appropriate spell ID when quick casting from scroll or staff 2022-04-10 17:32:16 +02:00
qndel a6ebc506a0 refresh stats when sending an item to stash by ctrl + click 2022-03-31 14:50:10 +02:00
staphen 33338115f6 Don't use HoldItem in CMD_PUTITEM handler 2022-03-31 11:43:58 +02:00
staphen 6a30cd3950 Add gamepad support for stash 2022-03-30 23:12:09 +02:00
staphen 82f53c53b0 Fix shift-click equipment swapping network messages 2022-03-27 18:26:43 +02:00
staphen 822a0cd22a Fix auto-equip network messages 2022-03-27 18:26:43 +02:00
Anders Jenbo e2fef44c9f Close gold withdraw when closing stash 2022-03-27 18:08:02 +02:00
ephphatha 4bbc2e56a0 Restore position of dropped note when recombining fragments 2022-03-27 03:40:44 +02:00
Anders Jenbo 1ba817ca53 Unify gold handling (withdraw any amount from stash) 2022-03-22 21:38:51 +01:00
Anders Jenbo 6d28810dc7 Change infostr from char[128] to std::string 2022-03-20 14:23:30 +01:00
Andrew James 4ff83431d2 Remove the use of HoldItem in AutoGetItem (#4178) 2022-03-19 14:32:54 +01:00
obligaron 92993ad039 Ctrl+click stash item swap: if there is no room left, don't drop the item on the ground 2022-03-19 14:30:44 +01:00
obligaron b495cabeb5 Allow to swap items with ctrl+click between inventory and stash 2022-03-19 08:29:04 +01:00
obligaron 05658de4e9 Make GetInventorySize public 2022-03-19 08:29:04 +01:00
Anders Jenbo be57d62684 Use UTF8 aware string copying 2022-03-19 06:03:19 +01:00
Anders Jenbo 718c46e7fe Remove use of tempstr 2022-03-19 06:03:19 +01:00
obligaron 2617332a41 Allow only one gold input panel to be open 2022-03-19 02:11:02 +01:00
Anders Jenbo a48f89007d Implement stash 2022-03-18 06:01:53 +01:00
ephphatha ca1ec8548f Move GoldAutoPlaceInInventorySlot to anonymous namespace 2022-03-06 06:33:11 +01:00
ephphatha f5da32a21c Don't assume holdItem when auto-placing gold 2022-03-06 06:33:11 +01:00
Andrew James f64d17bfa9 Initial clean up of code related to creating items (#2943)
* Move declaration of dItems to items.cpp

This array is never used in dungeon generation, it's closely related to Items so should be kept together. Ideally managing dItems can become responsibility of a container for Items, which will handle adding/removing items from the list and keeping the positions in sync.

* Rename SetPlrHandItem to match purpose/use

* Give more descriptive name to GetPlrHandSeed

This function sets a new seed on a given item struct, not just the held item.

* Don't use HoldItem as a temporary for the players initial inventory

* Take Item by reference in RespawnItem

* Don't use holdItem as a temporary when dropping gold on death

* Update DeadItem to take item by reference, and refer to it consistently

Move code which invalidates the source of dropped items to the caller

Most call sites use a temporary item instance or remove the item from the container, so there's no real point invalidating the item after it's been copied to the drop list.

Update DeadItem to take position instead of player references
2022-03-06 14:53:29 +11:00
Gleb Mazovetskiy 7fede6c4cb Clean up owned/unowned CelSprite ambiguity
Makes `CelSprite` unowned and adds a new `OwnedCelSprite` class for
owned sprites.

This clarifies ownership and makes the code cleaner in a number of
places.

Additionally, because the `CelSprite` class is now tiny (1 less
pointer), we can pass it by-value instead of by-reference, removing a
pointer indirection in the rendering functions.
2022-03-06 04:49:13 +01:00
qndel be0845f41d barb 2h cleanup 2022-03-04 19:45:20 +01:00
staphen 331072cdcf Persist the placed item in AutoPlaceItemInInventorySlot() 2022-02-26 00:14:27 +01:00
ephphatha eeb9ac3303 Sync dropped items if another player triggers an action on the current level 2022-01-24 21:12:13 +01:00
ephphatha db1d776539 Deduplicate PItem and DItem 2022-01-24 21:12:13 +01:00
Anders Jenbo 6b2481a76c Touch support on all SDL2 platforms 2022-01-02 11:37:38 +01:00
ephphatha 77a783098d Use ObjectAtPosition when checking if an item can be dropped
This extracts some of the common object logic from ItemSpaceOk and CanPut, these functions are almost identical except for the way players and monsters are checked...
2021-12-28 16:01:37 +01:00
ephphatha e633d7ff1e Restrict dropping items to adjacent tiles
This more closely matches vanilla behaviour until more intelligent dropping item behaviour is implemented (see #3489)
2021-12-28 15:56:55 +01:00
Anders Jenbo 6d346c7e18 Use std::string in PrintItemPower 2021-12-13 01:02:07 +01:00
ephphatha bda0a0624b Replace some usages of Item.statFlag 2021-12-12 20:07:05 +01:00
Andrew James a1a64ef32e fix negated check in SyncGetItem
I missed this when resolving merge conflicts :/
2021-12-07 00:44:34 +01:00
obligaron ff5de056fa Add all (boolean) Game Settings to Settingsmenu (#3616) 2021-11-26 23:43:46 +01:00
Gleb Mazovetskiy c57644970f Move UiFlags and UiPanels into their own files
The first breaks circular dependency between `DiabloUI` and `text_render`.
The latter one moves `UiPanels` to a more appropriate place.
2021-11-25 12:22:27 +01:00
Andrew James 4a940b1b07 Remove uses of Items[] as a temporary for other Item variables (#2924) 2021-11-25 09:34:13 +01:00