mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 20:37:05 +02:00
MISC: Remove APIs that were deprecated a long time ago (#2088)
This commit is contained in:
@@ -97,7 +97,6 @@ import { ScriptDeath } from "./Netscript/ScriptDeath";
|
||||
import { getBitNodeMultipliers } from "./BitNode/BitNode";
|
||||
import { assert, assertArray, assertString, assertObject } from "./utils/TypeAssertion";
|
||||
import { escapeRegExp } from "lodash";
|
||||
import numeral from "numeral";
|
||||
import { clearPort, peekPort, portHandle, readPort, tryWritePort, writePort, nextPortWrite } from "./NetscriptPort";
|
||||
import { FilePath, resolveFilePath } from "./Paths/FilePath";
|
||||
import { hasScriptExtension } from "./Paths/ScriptFilePath";
|
||||
@@ -106,7 +105,7 @@ import { ContentFilePath } from "./Paths/ContentFile";
|
||||
import { hasContractExtension } from "./Paths/ContractFilePath";
|
||||
import { getRamCost } from "./Netscript/RamCostGenerator";
|
||||
import { getEnumHelper } from "./utils/EnumHelper";
|
||||
import { setDeprecatedProperties, deprecationWarning } from "./utils/DeprecationHelper";
|
||||
import { deprecationWarning } from "./utils/DeprecationHelper";
|
||||
import { ServerConstants } from "./Server/data/Constants";
|
||||
import { assertFunctionWithNSContext } from "./Netscript/TypeAssertion";
|
||||
import { Router } from "./ui/GameRoot";
|
||||
@@ -1637,30 +1636,11 @@ export const ns: InternalAPI<NSFull> = {
|
||||
const multStart = helpers.number(ctx, "multStart", _multStart);
|
||||
return formatPercent(n, fractionalDigits, multStart);
|
||||
},
|
||||
// Todo: Remove function for real though in 2.4. Until then it just directly wraps numeral.
|
||||
nFormat: (ctx) => (_n, _format) => {
|
||||
deprecationWarning(
|
||||
"ns.nFormat",
|
||||
"Use ns.formatNumber, ns.formatRam, ns.formatPercent, or JS built-in objects/functions (e.g., Intl namespace) instead. " +
|
||||
"Check the NS API documentation for details.",
|
||||
);
|
||||
const n = helpers.number(ctx, "n", _n);
|
||||
const format = helpers.string(ctx, "format", _format);
|
||||
return numeral(n).format(format);
|
||||
},
|
||||
tFormat: (ctx) => (_milliseconds, _milliPrecision) => {
|
||||
const milliseconds = helpers.number(ctx, "milliseconds", _milliseconds);
|
||||
const milliPrecision = !!_milliPrecision;
|
||||
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
||||
},
|
||||
getTimeSinceLastAug: () => () => {
|
||||
deprecationWarning(
|
||||
"ns.getTimeSinceLastAug()",
|
||||
"Use `Date.now() - ns.getResetInfo().lastAugReset` instead. Please note that ns.getResetInfo().lastAugReset does NOT return the " +
|
||||
"same value as ns.getTimeSinceLastAug(). Check the NS API documentation for details.",
|
||||
);
|
||||
return Player.playtimeSinceLastAug;
|
||||
},
|
||||
alert: (ctx) => (_message) => {
|
||||
const message = helpers.string(ctx, "message", _message);
|
||||
dialogBoxCreate(message, { html: true, canBeDismissedEasily: true });
|
||||
@@ -1769,23 +1749,6 @@ export const ns: InternalAPI<NSFull> = {
|
||||
entropy: Player.entropy,
|
||||
karma: Player.karma,
|
||||
};
|
||||
setDeprecatedProperties(data, {
|
||||
playtimeSinceLastAug: {
|
||||
identifier: "ns.getPlayer().playtimeSinceLastAug",
|
||||
message: "Use ns.getResetInfo().lastAugReset instead. This is a static timestamp instead of an elapsed time.",
|
||||
value: Player.playtimeSinceLastAug,
|
||||
},
|
||||
playtimeSinceLastBitnode: {
|
||||
identifier: "ns.getPlayer().playtimeSinceLastBitnode",
|
||||
message: "Use ns.getResetInfo().lastNodeReset instead. This is a static timestamp instead of an elapsed time.",
|
||||
value: Player.playtimeSinceLastBitnode,
|
||||
},
|
||||
bitNodeN: {
|
||||
identifier: "ns.getPlayer().bitNodeN",
|
||||
message: "Use ns.getResetInfo().currentNode instead",
|
||||
value: Player.bitNodeN,
|
||||
},
|
||||
});
|
||||
return data;
|
||||
},
|
||||
getMoneySources: () => () => ({
|
||||
@@ -1870,6 +1833,14 @@ export const ns: InternalAPI<NSFull> = {
|
||||
// Removed functions
|
||||
setRemovedFunctions(ns, {
|
||||
getServerRam: { version: "2.2.0", replacement: "getServerMaxRam and getServerUsedRam" },
|
||||
nFormat: {
|
||||
version: "3.0.0",
|
||||
replacement: "ns.formatNumber, ns.formatRam, ns.formatPercent, or JS built-in objects/functions",
|
||||
},
|
||||
getTimeSinceLastAug: {
|
||||
version: "3.0.0",
|
||||
replacement: "Date.now() - ns.getResetInfo().lastAugReset",
|
||||
},
|
||||
});
|
||||
|
||||
export function NetscriptFunctions(ws: WorkerScript): NSFull {
|
||||
|
||||
Reference in New Issue
Block a user