Skip to content
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

BUGFIX: Hashserver UI shows wrong server list when purchasing upgrades #1782

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

catloversg
Copy link
Contributor

#1779 accidentally reverts the fix in #1665 and adds unexpected servers to the server list. How to reproduce this regression bug:

  • Load a clean save file with SF9.
  • Buy a hashserver.
  • Buy a private server (p-server-0).
  • Hacknet -> Spend Hashes on Upgrades -> Reduce Minimum Security -> Open the drop-down list. It will contain home, p-server-0, and hacknet-server-0.

The problem is in this code:

return s.hostname !== "home" && !purchased && !Player.hasAugmentation(AugmentationName.TheRedPill, true)
  ? s.hostname !== "w0r1d_d43m0n"
  : true;

When s is home, private servers, or hashservers, it always returns true.

While fixing this bug, I spotted other wrong logic in this file, so I fixed all of them in this PR. Those code paths are currently not used (ServerDropdown is only used by src\Hacknet\ui\HacknetUpgradeElem.tsx, and HacknetUpgradeElem.tsx only uses ServerType.Foreign.), so it's not a problem.

Code in isValidServer does not check members of ServerType properly:

  • purchased is checked by (s instanceof Server && s.purchasedByPlayer) || s instanceof HacknetServer, but home also satisfies s instanceof Server && s.purchasedByPlayer, so purchased is in fact isOwnedServer (home, private servers, hashservers), not Everything from Owned except home computer.
  • s.hostname !== "home" is used in wrong places.

@d0sboots To avoid making a breaking change with ns.hacknet.spendHashes (https://github.com/bitburner-official/bitburner-src/blob/d824cd4fa6692ca1e04173b892278b79587a88fb/src/Hacknet/HacknetHelpers.tsx), I don't touch it in this PR, but I want to hear your opinions about it:

  • When it sees a hashserver, it returns false without printing a warning.
  • Home and private servers are valid targets. It's inconsistent with how we determine the target in the UI. It's not exploitable, so it's not urgent.

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.

1 participant