BUGFIX: Hashserver UI shows wrong server list when purchasing upgrades #1782
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#1779 accidentally reverts the fix in #1665 and adds unexpected servers to the server list. How to reproduce this regression bug:
The problem is in this code:
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 bysrc\Hacknet\ui\HacknetUpgradeElem.tsx
, andHacknetUpgradeElem.tsx
only usesServerType.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 satisfiess instanceof Server && s.purchasedByPlayer
, sopurchased
is in factisOwnedServer
(home, private servers, hashservers), notEverything 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: