Skip to content

Fix UGC Templates stacking - #421

Merged
AngeloTadeucci merged 3 commits into
masterfrom
ugc
Apr 23, 2025
Merged

Fix UGC Templates stacking#421
AngeloTadeucci merged 3 commits into
masterfrom
ugc

Conversation

@AngeloTadeucci

@AngeloTadeucci AngeloTadeucci commented Apr 22, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Improved support for handling and storing cubes with unique templates in housing and furnishing systems.
    • Added ability to remove items from furnishing storage directly via in-game commands.
  • Bug Fixes

    • Enhanced item storage logic to correctly handle items with template variations, preventing storage conflicts.
  • Chores

    • Removed obsolete item creation methods to streamline item management and maintenance.

@coderabbitai

coderabbitai Bot commented Apr 22, 2025

Copy link
Copy Markdown
Contributor
## Walkthrough

This set of changes updates the handling of cubes and item storage in the game server's furnishing and inventory systems. The `FurnishingManager` now supports adding cubes directly from `HeldCube` objects and distinguishes stored items by both item ID and template. The `AddStorage` method is refactored to accept an optional template parameter, and related method calls throughout the codebase are updated accordingly. Additionally, obsolete item creation methods are removed from the `ItemManager`, streamlining item instantiation and color assignment logic. A new packet handler for furnishing storage commands is added, and the item update packet now explicitly includes the item UID.

## Changes

| File(s)                                                                                  | Change Summary                                                                                                                      |
|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| Maple2.Server.Game/Manager/HousingManager.cs                                             | Modified `TryPlaceCube` to call `AddCube` with a `HeldCube` object instead of just the cube's item ID.                              |
| Maple2.Server.Game/Manager/Items/FurnishingManager.cs                                    | Added `AddCube(HeldCube cube)` and refactored `AddStorage` to accept `Item item, UgcItemLook? template`. Updated storage logic to handle templates and direct `HeldCube` addition. Added `RemoveItem(long itemUid)` method. |
| Maple2.Server.Game/Manager/Items/InventoryManager.cs                                     | Updated call to `AddStorage` to pass both the item and its template.                                                                |
| Maple2.Server.Game/Manager/Items/ItemManager.cs                                          | Removed obsolete `CreateItem` and `GetColor` methods, eliminating legacy item creation and color assignment logic.                  |
| Maple2.Server.Core/Packets/UgcPacket.cs                                                  | Updated `UpdateItem` method signature to include explicit `uid` parameter and use it when writing item UID in the packet.           |
| Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs                            | Added new packet handler class to process furnishing storage commands, currently supporting item deletion by UID.                   |
| Maple2.Server.Game/PacketHandlers/UgcHandler.cs                                          | Modified `ConfirmItem` method to use `AddCube` return UID for furniture items and create items via DB for others, updating packet calls accordingly. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant HousingManager
    participant FurnishingManager
    participant InventoryManager
    participant Database
    participant UgcHandler

    HousingManager->>FurnishingManager: AddCube(HeldCube cube)
    FurnishingManager->>FurnishingManager: AddStorage(Item from cube, cube.Template)
    FurnishingManager->>InventoryManager: Return item UID

    UgcHandler->>FurnishingManager: AddCube(HeldCube cube) [if Furniture]
    UgcHandler->>Database: CreateItem(characterId, item) [if not Furniture]
    Database-->>UgcHandler: new item UID
    UgcHandler->>InventoryManager: Add(item, notifyNew=true)
    UgcHandler->>UgcPacket: UpdateItem(objectId, uid, item, createPrice, ugcType)

Possibly related PRs

  • AngeloTadeucci/Maple2#228: Refactors and overloads in FurnishingManager closely related to handling cubes and template-aware storage logic.

Suggested reviewers

  • Zintixx

Poem

In the warren where cubes are stored with care,
Rabbits hop and templates pair.
Obsolete methods now hop away,
As new logic guides where cubes will stay.
With slots and templates, order grows—
The warren’s inventory smartly flows!
🐇✨


<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 8a3bf8d2930f102cd11e0404c7b5080040aad1e9 and 763df801d1d22d186af0cd95095918713636b162.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (2)</summary>

* GitHub Check: build
* GitHub Check: build

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEejqANiS4AxeAA9IAVQDiAYRglm3C9WmREXDQGAGt4DCIDADlsZgFKLgAWACYARgMnRATIAEEIkgt8aDQlbAYGeCN9Y3AoMnp8ADMcAmIyZRp6JlZ2Ll5+YVFxKRl5JiUqVXUtHWqTKDhUVEwWwlJyKk6FHoxOSCoAdwDY5jQKeTkFCZU1TW1dMEMa0wMAWTQfEmSNAGVKKQoGhcaDYAHp3hg0KQKKCABL4bCIcJECFQygaBiIDgGABEeIMAGICbkAJJtDZ+eiIE5neRNRiwTCkRBmWAkBlM9nMRTwRrwfy4NnoChEWLsHhoRBZegESCC9kAAxytFobmw8QVkDYgsU/Ga8sgCps2AoGCQCAimsEIjEkAO6gtcqFCug5wACr4GCQ1RqtSQdbQNJA3RQSBJ4AjEBZZAAaJ1c/2wXUHSWMNAWKz0e2Cw0MdUkDQkmjMEm0TUAChW4Ro0P2JF40nYyPjKGLKCUu15/IoAEogzlGjQ+AaGIz8nH1ChkAx05m7Q6W03Q7n81bBrby/TcLJuIrYQVVau+zAEMg0I1GkNkAbCkR4Aw7Wzl2hGPmp+gVXQ5fgW40TWbEAtIgAgIKhSBQZpJxnDAMHwXBIHiHhPS/Wh4FDMRoyDOB2VDQI9RbJhdgofALEgRpCgOONKGIvgx1oCxkTjTAqXVLIAEdsHFQJ62QUNTnCSBsAwUdOUDIwiVyCwh2oCMMGvH8DSUBhfE2WTkHpEh7G4fAKC2HSeHVBiHybcRpCqSAoh/ET8nklskSISFcBNfwNK0nS9L4bhDPvSATP5ZADkoLkSgLXF8QMCAwCMd5Pm+P4KABIEQRIcFMDRGEiy8RBQWNU1zWRV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anks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=AngeloTadeucci/Maple2&utm_content=421):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Generate unit testing code for this file.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai generate unit testing code for this file.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and generate unit testing code.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

feat: delete extra cubes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 397ea7b and 8a3bf8d.

📒 Files selected for processing (4)
  • Maple2.Server.Core/Packets/UgcPacket.cs (2 hunks)
  • Maple2.Server.Game/Manager/Items/FurnishingManager.cs (5 hunks)
  • Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs (1 hunks)
  • Maple2.Server.Game/PacketHandlers/UgcHandler.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Maple2.Server.Game/Manager/Items/FurnishingManager.cs
🧰 Additional context used
🧬 Code Graph Analysis (1)
Maple2.Server.Game/PacketHandlers/UgcHandler.cs (4)
Maple2.Server.Game/Manager/Items/FurnishingManager.cs (5)
  • Item (67-71)
  • Item (73-77)
  • AddCube (155-170)
  • AddCube (173-188)
  • AddCube (190-205)
Maple2.Server.Game/Manager/Items/InventoryManager.cs (2)
  • Item (560-568)
  • Add (149-254)
Maple2.Database/Storage/Game/GameStorage.Item.cs (7)
  • Item (13-20)
  • Item (22-32)
  • Item (50-57)
  • Item (184-190)
  • GameStorage (11-192)
  • Request (12-191)
  • UpdateItem (142-147)
Maple2.Server.Core/Packets/UgcPacket.cs (1)
  • UgcPacket (12-231)
🪛 GitHub Actions: Format
Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs

[error] 8-8: dotnet format whitespace error: Fix whitespace formatting. Insert '\s'.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (9)
Maple2.Server.Core/Packets/UgcPacket.cs (2)

79-79: Good improvement in parameter clarity.

The explicit uid parameter makes the method signature clearer and more flexible compared to implicitly accessing item.Uid inside the method.


97-97: Correctly using the explicit UID parameter.

This change ensures the packet contains the UID provided by the caller rather than implicitly relying on item.Uid, which aligns with the method signature update.

Maple2.Server.Game/PacketHandlers/UgcHandler.cs (4)

451-452: Good practice: tracking UID explicitly.

Introducing a dedicated variable for tracking the item UID improves code clarity and makes the flow easier to follow.


454-456: Clean implementation of furniture-specific logic.

The code now correctly delegates to the specialized AddCube method in the furnishing manager for furniture items, addressing the UGC templates stacking issue mentioned in the PR title.


457-466: Robust database item creation with error handling.

The implementation properly:

  1. Creates a database context with using
  2. Creates the item in the database for the character
  3. Checks for null (failure) and logs an error
  4. Extracts the UID from the new item
  5. Adds the item to inventory with notification

This is a significant improvement over previous code.


468-468: Consistent with the packet API update.

This line correctly uses the explicit UID parameter when calling UgcPacket.UpdateItem, matching the method signature change in UgcPacket.cs.

Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs (3)

11-13: Appropriately defines the command enum.

The enum definition follows the standard pattern in the codebase, with the Delete command properly defined with value 6.


15-22: Standard packet handler implementation.

The Handle method correctly follows the established pattern for packet handlers by reading the command and dispatching to the appropriate handler method.


24-27: Clean and focused delete handler.

The HandleDelete method is properly implemented to:

  1. Read the item UID from the packet
  2. Call the appropriate method on the furnishing manager

This complements the changes in the UGC handler and provides a clean way to remove items from furnishing storage.

Comment thread Maple2.Server.Game/PacketHandlers/FurnishingStorageHandler.cs Outdated
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.

2 participants