Commit Graph

469 Commits

Author SHA1 Message Date
David Walker
b51ed8fd59 BUG: Fix missed cases in offline server handling (#2495)
There were two large holes in the existing offline server handling:

1. It didn't include IPs, so scripts that used IPs instead of hostnames
   would get exceptions thrown for "server not found."
2. Coverage was very low for non-Darknet APIs. Maybe most of them don't
   need to be covered, but many obvious ones like "ps", "killall" and
   "hasRootAccess" were missing. IMO the only reliable answer is one
   that enforces *all* are covered via the type system.

To accomplish the second part, helpers.getServer() was changed to return
null when a server is offline. This intentionally breaks a lot of its
utility, which was to return a server unconditionally. To compensate,
its utility was increased - it now also does unknown argument
processing, allowing it to subsume a common line that all callers were
repeating.

Some callers switched to ctx.workerScript.getServer(), because they
didn't actually need to be using helpers.getServer(). Similarly, a few
callsites switched to GetServerOrThrow(), for the cases where it should
be guaranteed that the server is valid. The rest are returning a
default/failure response when the server is offline. (Except for
contracts, which threw on failure already anyway.)
2026-02-15 10:29:47 -08:00
catloversg
68700ff01f API: Expose ProgramName enum (#2492) 2026-02-13 11:51:42 -08:00
David Walker
62f7501b43 REFACTOR: Change getFailureResult to checkDarknetServer (#2494) 2026-02-11 08:42:27 -08:00
David Walker
b5da311133 REFACTOR: Consolidate checks under getFailureResult() (#2476)
There was duplicated code, and more importantly, were were handling
certain things subtly differently in exec() and scp() as a result. This
notably causes a behavior change in exec() and scp() where failure to
authenticate now returns failure instead of throwing, which I believe is
the proper response.

This also makes it easier to see in the code exactly which functions
require what (auth, session, etc.)
2026-02-08 08:39:42 -08:00
Michael Ficocelli
425bff8217 DNET: Update documentation (#2483) 2026-02-07 19:25:56 -08:00
Michael Ficocelli
6073964768 DARKNET: Darkweb Expansion Project & Bitnode (#2139)
This is BN15. It is a really big change; see the PR for all the details.
2026-02-03 03:40:36 -08:00
catloversg
5f519991a6 API: Allow ns.read to read .msg and .lit files (#2455) 2026-01-25 20:32:44 -08:00
David Walker
50b0cc2808 MISC: Refactor implementation of ports (#2396)
This moves the implementation entirely into the PortHandle class, which
makes the code a bit more streamlined and will allow for other port
implementations in the future.
2025-11-22 17:52:25 -08:00
gmcew
7c0286222c API: Move and rename purchased server functions to cloud API (#2367)
* Convert purchased server functions to cloud API

- Create `ns.cloud`
- Change `bitnode multipliers` and `server constants` wording for consistency
- change `server`, `ram` and `getting started` docs for consistency
- Added changes to 3.0.0 API Break and `setRemovedFunctions` in NetscriptFunctions.js

Tested by
- running tutorial `purchase-server-8gb.js`, and a more typical player one
- buying manually using vendor (Alpha Ent in Sector 12)
- deleting them all using script, and checked all deleted functions gave correct error
- Imported completed save to ensure auto-transfer of function work

* Revision in line with comments

- changed more `purchased` to `cloud` references
- Added BN mults auto-conversion

* Update getting_started.md

 - Corrected function names for new `cloud API`

* Don't show `cloud API` warning

v3.0.0 API break auto-replaces `cloud` functions, not warning suggested.

* API Break correction

- `cloud` affected API break replacement changed to be more descriptive and functional

* Fix typo and add empty lines

* Update many things (check commit's description)

- Comments
- Terminal message
- UI Text
- TSDoc
- md docs
- Improve error messages in src\NetscriptFunctions\Cloud.ts
2025-11-07 12:10:33 -08:00
Shy
4ad9a96788 MISC: Support css file type (#2378) 2025-11-05 14:05:31 -08:00
catloversg
6837f334fd CODEBASE: Remove redundant check in getServer utility function and serverExists API (#2357) 2025-10-19 11:45:30 -07:00
Adam Weeden
0335d8bc70 STANEK: Add FragmentType to NS Enums (#2341) 2025-10-13 08:57:19 -07:00
Victor Oliveira
2d8401eaae Change alert to accept multiple args as other print functions (#2278) 2025-08-04 09:25:06 -07:00
catloversg
8729dc3d1b MISC: Update messages related to text files (#2266) 2025-07-24 22:39:55 -07:00
catloversg
fee75b44d4 BUGFIX: ns.mv writes to destination file even if it cannot delete source file (#2267) 2025-07-24 22:38:55 -07:00
Chris Farfan de los Godos
8f69a6c0ee COMMAND: Improving error message for mv when a script is Running
* Adjusted error message to include information about making sure scripts are not running when trying to use mv on them.

* nom run format

* Added behaviour info to NetscriptDefinitions.d.ts

* `npm run doc`

* un-nested/inversed the check

* `npm run format`
2025-07-23 16:27:01 -07:00
catloversg
6bf501fb78 API: Make some APIs throw error when server is invalid (#2261) 2025-07-23 14:20:20 -07:00
catloversg
a794fddaf7 MISC: Add file metadata (timestamps) (#2199) 2025-06-16 16:34:06 -07:00
catloversg
2cabb98095 API: Rename BN multiplier RepToDonateToFaction to FavorToDonateToFaction (#2178) 2025-06-03 01:21:59 -07:00
catloversg
98f6cc9554 MISC: Make nuke and port cracking APIs return false instead of throwing error (#2153) 2025-05-31 21:28:50 -07:00
catloversg
296295b490 API: Add more enums to ns.enums (#2165) 2025-05-30 03:37:59 -07:00
catloversg
90555a64e6 MISC: Add achievements for BN14 (#2140) 2025-05-20 14:32:13 -07:00
catloversg
37d9284d33 MISC: Remove deprecated tail-related APIs (#2143) 2025-05-19 20:10:15 -07:00
G4mingJon4s
2b8c008be1 NETSCRIPT: Moved formatting functions to their own interface (#1635) 2025-05-14 09:13:35 -07:00
catloversg
b53180ff1e MISC: Remove APIs that were deprecated a long time ago (#2088) 2025-05-10 22:10:48 -07:00
catloversg
31e6e4d74b MISC: Enforce stricter param check on ns.getBitNodeMultipliers and ns.hacknet.spendHashes (#2085) 2025-04-14 16:20:36 -07:00
Naga
0aaa28054a NETSCRIPT: Add functionality and support to fully allow Players to use IP addresses in place of hostnames (#1990) 2025-04-10 18:41:37 -07:00
Shy
d28a06e764 API: dynamic imports with ns.dynamicImport() (#2036) 2025-04-09 18:49:01 -07:00
catloversg
41c497161f UI: Make BN-hint popups harder to be dismissed accidentally (#2021) 2025-03-22 23:59:38 -07:00
Naga
b0165d5c2c NETSCRIPT: Store the value of Player.money in the returned object's moneyAvailable property when ns.getServer is called with "home" (#2024) 2025-03-12 18:17:57 -07:00
catloversg
4ef597bd37 BUGFIX: Some calculations return NaN due to Player.playtimeSinceLastAug being 0 in edge cases (#1985) 2025-03-01 09:06:58 -08:00
catloversg
d6ee16cdb3 API: Move tail-related APIs to another namespace (#1935)
* API: Move tail-related APIs to another namespace

* Add missing RAM cost config

* Remove setTailFontSize from NS namespace
2025-02-01 21:43:56 -08:00
catloversg
2965f51879 API: Add a way to get the list of all factions (#1457) 2025-01-28 10:40:11 -08:00
G4mingJon4s
ffae0045a4 CODINGCONTRACT: Add support for other answer formats (#1892) 2025-01-26 09:35:04 -08:00
catloversg
b161142796 API: Add ns.renderTail (#1815) 2025-01-25 09:14:45 -08:00
catloversg
9bf408221c CODEBASE: Merge TypeAssertion files (#1922) 2025-01-24 11:06:39 -08:00
Yichi Zhang
e6a1c344d3 NETSCRIPT: Log script kill immediately and identify the killing script. (#1907) 2025-01-12 21:07:01 -08:00
catloversg
8c19165323 BUGFIX: Grow log shows invalid values in edge cases (#1872) 2025-01-08 18:48:45 -08:00
catloversg
1cb2a83b4f UI: Share RAM to boost reputation gain (#1862) 2025-01-07 22:35:29 -08:00
G4mingJon4s
c622291eff NETSCRIPT: Added changing tail font size through scripts (#1852) 2025-01-04 16:51:13 -08:00
nanogyth
85fa15c5a5 BUGFIX: update weaken results to correctly reflect change when close to minSecurity (#1887) 2024-12-29 18:08:55 -08:00
Jon Hartnett
99aeecbd0e BUGFIX: Fix ramOverride check (#1787)
ramOverride currently prevents you from actually using exactly all of a server's memory due to a bug in the ram check. Simply replace ">=" with ">" to allow the new ram to equal the max ram.

Test script:
```js
/** @param {NS} ns */
export async function main(ns) {
  ns.tprint(ns.ramOverride(8));
}
```
Expected output (on fresh save):
```js
8
```
Output before this commit:
```js
1.6
```
2024-11-20 12:47:55 -08:00
catloversg
75cf9c88b5 CODEBASE: Fix lint errors 3 (#1758)
This is a really big refactor because it actually *fixes* a lot of the lint errors instead of disabling them.
2024-11-14 08:18:57 -08:00
catloversg
72a63b15cb API: Return active SF levels in getOwnedSourceFiles and ResetInfo.ownedSF (#1761)
* DOCUMENTATION: Clarify getOwnedSourceFiles when player overrides active levels of SFs
* Return Player.activeSourceFiles instead of Player.sourceFiles
* Get rid of zeroes in the map
2024-11-10 22:56:57 -08:00
catloversg
650cf51acb DOCUMENTATION: Add more information for deprecated nFormat API (#1762) 2024-11-10 16:27:35 -08:00
catloversg
f6502dd490 CODEBASE: Fix lint errors 1 (#1732) 2024-11-03 22:35:14 -08:00
David Walker
424ae160ba NETSCRIPT: Fix dynamicRamUsage returned by getRunningScript() (#1704)
Fixes #1700
2024-10-20 00:52:57 -07:00
G4mingJon4s
651b17739c NETSCRIPT: Add ns.self() as a free info function (#1636)
* added utility info

* moved info to running script

* fix for RAM cost

* description changes

Co-authored-by: David Walker <d0sboots@gmail.com>

* fixed wrong formatting

* Added parent to ignored fields

---------

Co-authored-by: David Walker <d0sboots@gmail.com>
2024-09-07 17:34:24 -07:00
catloversg
94eef8ecde BUGFIX: Fix inconsistencies of error handling in promise-based API (#1377) 2024-08-17 14:23:08 -07:00
David Walker
34db6e8b26 NETSCRIPT: Rework disableLog for efficiency (#1589)
The current implementation was naive; disableLog("ALL") was storing a
key for every function, and iterating over a different object to do it
(when iterating over objects is quite slow).

The common cases of Bitburner (and especially batching, where efficiency
matters most) are either never disabling anything, or disabling "ALL".
This optimizes for these two cases, at the expense of slightly more
complicated code to deal with the less-common edge cases.
2024-08-16 19:10:20 -07:00