Skip to content

Conversation

@Mervandeli
Copy link
Contributor

@Mervandeli Mervandeli commented Aug 13, 2025

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

What is the current behaviour?

-Item Upgrade not implemented

What is the new behaviour?

-The CUIItemUpgrade class has been implemented, and the UI behaviors work the same as in the original 1298 Client. Items can be upgraded correctly.

Why and how did I change this?

-The items in the ItemUpgrade window are copied from the inventory and backed up. When the window is closed or the Cancel button is pressed, the items are restored from the backup. A backup is used to prevent errors when switching between Inventory and ItemUpgrade. If the upgrade process succeeds or fails, the backup is updated accordingly.

Checklist

  • I have performed a self-review of my own code.
  • Where applicable, I have checked to make sure that this doesn't introduce incompatible behaviour with the official 1.298 server (e.g. unofficial opcodes or behavioural differences).
  • I have checked to make sure that this change does not already exist in the codebase in some fashion (e.g. UI already implemented under a different name).

@Mervandeli
Copy link
Contributor Author

Scroll check and other reviews solved.

@Mervandeli
Copy link
Contributor Author

Mervandeli commented Jan 8, 2026

I used sn/itemupgrade, and it is compatible with @stefannikolei’s #743 PR. @twostars

@twostars twostars force-pushed the itemupgrade branch 10 times, most recently from 9390eb8 to 46d057f Compare January 11, 2026 08:33
Copy link
Collaborator

@twostars twostars left a comment

Choose a reason for hiding this comment

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

I want to get #743 in before this, just to make life a little bit easier.

The item/icon data management here really leaves a lot to be desired though.
All of this (the reliance on the item having a given stack size and being stackable to determine how to handle the item/icon data) is a giant red flag for potential problems:

				if (spItem->iCount > 1 && spItem->IsStackable())
				{
					// Clean divided item
					if (spItem != nullptr)
					{
						if (spItem->pUIIcon != nullptr)
						{
							delete spItem->pUIIcon;
							spItem->pUIIcon = nullptr;
						}

						if (m_pSelectedItem == spItem)
							m_pSelectedItem = nullptr;

						delete spItem;
						spItem = nullptr;
					}
				}
				else
				{
					// Restore the icon position to its original place if drop failed.
					CancelIconDrop(spItem);
				}

Even off-handedly, without looking closer at it, I have to wonder how that handles it when it splits from a stack of 2, for example. That is, potentially, it splits creating a new instance, ends up with a stack of 1, so it doesn't consider it a managed instance and doesn't free it when the time comes.

Regardless of whether or not that's actually the case here, it would be better to just simplify so there's no question as to how things behave without having to dive through all of the associated code.

But yeah, once the server part of it's in, and the icon stuff's cleaned up, it should be fine to merge.

@Mervandeli
Copy link
Contributor Author

@twostars Now, stack of 2 splits correctly. I’ll wait for #743 to be merged, then I’ll try to handle it in a different way.

@twostars
Copy link
Collaborator

Be sure the file is formatted. CTRL+K -> D will reformat the entire document.
This will use clang-format automatically; VS includes it.

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.

3 participants