-
Notifications
You must be signed in to change notification settings - Fork 187
bugfix(player): Fix transferred in-progress upgrades #2396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
5a61f29
48b246b
8ccd9d3
9fc16a4
4b2c5d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2116,6 +2116,18 @@ void Player::setObjectsEnabled(AsciiString templateTypeToAffect, Bool enable) | |
| } | ||
| } | ||
|
|
||
| //============================================================================= | ||
| static void cancelUpgradeInProduction(Object* obj, void* userData) | ||
| { | ||
| const UpgradeTemplate* upgradeTemplate = (const UpgradeTemplate*)userData; | ||
|
xezon marked this conversation as resolved.
Outdated
|
||
| ProductionUpdateInterface* pui = ProductionUpdate::getProductionUpdateInterfaceFromObject(obj); | ||
|
|
||
| if (pui && pui->isUpgradeInQueue(upgradeTemplate)) | ||
| { | ||
| pui->cancelUpgrade(upgradeTemplate); | ||
| } | ||
| } | ||
|
|
||
| //============================================================================= | ||
| void Player::transferAssetsFromThat(Player *that) | ||
| { | ||
|
|
@@ -2124,6 +2136,32 @@ void Player::transferAssetsFromThat(Player *that) | |
| return; | ||
| } | ||
|
|
||
| #if !RETAIL_COMPATIBLE_CRC | ||
| // TheSuperHackers @bugfix Stubbjax 03/02/2026 Cancel any in-progress player upgrades 'that' | ||
| // player currently has in progress that 'this' player already has in progress or completed. | ||
| std::vector<const UpgradeTemplate*> upgradesToCancel; | ||
| for (Upgrade* upgrade = that->m_upgradeList; upgrade; upgrade = upgrade->friend_getNext()) | ||
| { | ||
| const UpgradeTemplate* upgradeTemplate = upgrade->getTemplate(); | ||
|
|
||
| if (upgrade->getStatus() == UPGRADE_STATUS_IN_PRODUCTION | ||
| && upgradeTemplate->getUpgradeType() == UPGRADE_TYPE_PLAYER | ||
| && (hasUpgradeComplete(upgradeTemplate) || hasUpgradeInProduction(upgradeTemplate))) | ||
| { | ||
| upgradesToCancel.push_back(upgradeTemplate); | ||
| } | ||
| } | ||
|
|
||
| for (const UpgradeTemplate* upgradeTemplate : upgradesToCancel) | ||
|
xezon marked this conversation as resolved.
Outdated
|
||
| { | ||
| that->iterateObjects(cancelUpgradeInProduction, (void*)upgradeTemplate); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. void* cast should be implicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was unchanged. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you plan to remove the void* cast?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that not invalid for const pointers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use const_cast then.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but static_cast is not necessary to void*. All pointers implicitly convert to void pointer. The idea here is to remove void* cast because it is a C cast and it is best practice to avoid them in C++ code, because they cast every pointer with no restrictions which can be a source of error in some situations. |
||
| } | ||
|
|
||
| // TheSuperHackers @bugfix Stubbjax 03/02/2026 Ensure the in-progress upgrade mask is copied from 'that' | ||
| // player to 'this' player to prevent duplicate player upgrades being purchased. | ||
| m_upgradesInProgress.set(that->m_upgradesInProgress); | ||
| #endif | ||
|
|
||
| std::list<Object *> objsToTransfer; | ||
|
|
||
| // let's not transfer beacons | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static_cast