mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-30 09:57:32 +01:00
fix a few things about getRecentScritps
This commit is contained in:
parent
a9b03f34ab
commit
52e01fc026
@ -15,6 +15,7 @@ export const RamCostConstants: IMap<number> = {
|
|||||||
ScriptWeakenRamCost: 0.15,
|
ScriptWeakenRamCost: 0.15,
|
||||||
ScriptWeakenAnalyzeRamCost: 1,
|
ScriptWeakenAnalyzeRamCost: 1,
|
||||||
ScriptScanRamCost: 0.2,
|
ScriptScanRamCost: 0.2,
|
||||||
|
ScriptRecentScriptsRamCost: 0.2,
|
||||||
ScriptPortProgramRamCost: 0.05,
|
ScriptPortProgramRamCost: 0.05,
|
||||||
ScriptRunRamCost: 1.0,
|
ScriptRunRamCost: 1.0,
|
||||||
ScriptExecRamCost: 1.3,
|
ScriptExecRamCost: 1.3,
|
||||||
@ -140,7 +141,7 @@ export const RamCosts: IMap<any> = {
|
|||||||
scp: RamCostConstants.ScriptScpRamCost,
|
scp: RamCostConstants.ScriptScpRamCost,
|
||||||
ls: RamCostConstants.ScriptScanRamCost,
|
ls: RamCostConstants.ScriptScanRamCost,
|
||||||
ps: RamCostConstants.ScriptScanRamCost,
|
ps: RamCostConstants.ScriptScanRamCost,
|
||||||
getRecentScripts: RamCostConstants.ScriptScanRamCost,
|
getRecentScripts: RamCostConstants.ScriptRecentScriptsRamCost,
|
||||||
hasRootAccess: RamCostConstants.ScriptHasRootAccessRamCost,
|
hasRootAccess: RamCostConstants.ScriptHasRootAccessRamCost,
|
||||||
getIp: RamCostConstants.ScriptGetHostnameRamCost,
|
getIp: RamCostConstants.ScriptGetHostnameRamCost,
|
||||||
getHostname: RamCostConstants.ScriptGetHostnameRamCost,
|
getHostname: RamCostConstants.ScriptGetHostnameRamCost,
|
||||||
|
@ -5,15 +5,11 @@ import { WorkerScript } from "./WorkerScript";
|
|||||||
export const recentScripts: RecentScript[] = [];
|
export const recentScripts: RecentScript[] = [];
|
||||||
|
|
||||||
export function AddRecentScript(workerScript: WorkerScript): void {
|
export function AddRecentScript(workerScript: WorkerScript): void {
|
||||||
if (recentScripts.find((r) => r.pid === workerScript.pid)) return;
|
if (recentScripts.find((r) => r.runningScript.pid === workerScript.pid)) return;
|
||||||
|
|
||||||
const killedTime = new Date();
|
const killedTime = new Date();
|
||||||
recentScripts.unshift({
|
recentScripts.unshift({
|
||||||
filename: workerScript.name,
|
timeOfDeath: killedTime,
|
||||||
args: workerScript.args,
|
|
||||||
pid: workerScript.pid,
|
|
||||||
timestamp: killedTime,
|
|
||||||
timestampEpoch: killedTime.getTime(),
|
|
||||||
runningScript: workerScript.scriptRef,
|
runningScript: workerScript.scriptRef,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -23,10 +19,6 @@ export function AddRecentScript(workerScript: WorkerScript): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RecentScript {
|
export interface RecentScript {
|
||||||
filename: string;
|
timeOfDeath: Date;
|
||||||
args: string[];
|
|
||||||
pid: number;
|
|
||||||
timestamp: Date;
|
|
||||||
timestampEpoch: number;
|
|
||||||
runningScript: RunningScript;
|
runningScript: RunningScript;
|
||||||
}
|
}
|
||||||
|
@ -1462,7 +1462,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
},
|
},
|
||||||
getRecentScripts: function (): IRecentScript[] {
|
getRecentScripts: function (): IRecentScript[] {
|
||||||
updateDynamicRam("getRecentScripts", getRamCost(Player, "getRecentScripts"));
|
updateDynamicRam("getRecentScripts", getRamCost(Player, "getRecentScripts"));
|
||||||
return recentScripts.map((rs) => ({ ...rs, runningScript: createPublicRunningScript(rs.runningScript) }));
|
return recentScripts.map((rs) => ({
|
||||||
|
timeOfDeath: rs.timeOfDeath,
|
||||||
|
...createPublicRunningScript(rs.runningScript),
|
||||||
|
}));
|
||||||
},
|
},
|
||||||
ps: function (_hostname: unknown = workerScript.hostname): ProcessInfo[] {
|
ps: function (_hostname: unknown = workerScript.hostname): ProcessInfo[] {
|
||||||
updateDynamicRam("ps", getRamCost(Player, "ps"));
|
updateDynamicRam("ps", getRamCost(Player, "ps"));
|
||||||
|
14
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
14
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -136,19 +136,9 @@ export interface RunningScript {
|
|||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
interface RecentScript {
|
export interface RecentScript extends RunningScript {
|
||||||
/** Arguments the script was called with */
|
|
||||||
args: string[];
|
|
||||||
/** Filename of the script */
|
|
||||||
filename: string;
|
|
||||||
/** Process ID. Must be an integer */
|
|
||||||
pid: number;
|
|
||||||
/** Timestamp of when the script was killed */
|
/** Timestamp of when the script was killed */
|
||||||
timestamp: Date;
|
timeOfDeath: Date;
|
||||||
/** Numeric epoch of timestamp */
|
|
||||||
timestampEpoch: number;
|
|
||||||
/** An inactive copy of the last `RunningScript` associated to the script */
|
|
||||||
runningScript: RunningScript;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,8 +57,8 @@ export function RecentScriptAccordion(props: IProps): React.ReactElement {
|
|||||||
<ListItemText
|
<ListItemText
|
||||||
primary={
|
primary={
|
||||||
<Typography>
|
<Typography>
|
||||||
└ {recentScript.filename} (died{" "}
|
└ {recentScript.runningScript.filename} (died{" "}
|
||||||
{convertTimeMsToTimeElapsedString(new Date().getTime() - recentScript.timestamp.getTime())} ago)
|
{convertTimeMsToTimeElapsedString(new Date().getTime() - recentScript.timeOfDeath.getTime())} ago)
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@ -78,7 +78,7 @@ export function RecentScriptAccordion(props: IProps): React.ReactElement {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell className={classes.noborder} colSpan={2}>
|
<TableCell className={classes.noborder} colSpan={2}>
|
||||||
<Typography>└ Args: {arrayToString(recentScript.args)}</Typography>
|
<Typography>└ Args: {arrayToString(recentScript.runningScript.args)}</Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
@ -13,7 +13,7 @@ export function RecentScriptsPage(): React.ReactElement {
|
|||||||
<>
|
<>
|
||||||
<Typography>List of all recently killed scripts.</Typography>
|
<Typography>List of all recently killed scripts.</Typography>
|
||||||
{recentScripts.map((r) => (
|
{recentScripts.map((r) => (
|
||||||
<RecentScriptAccordion key={r.pid} recentScript={r} />
|
<RecentScriptAccordion key={r.runningScript.pid} recentScript={r} />
|
||||||
))}
|
))}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -196,7 +196,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
value={recentScriptsSize}
|
value={recentScriptsSize}
|
||||||
onChange={handleRecentScriptsSizeChange}
|
onChange={handleRecentScriptsSizeChange}
|
||||||
step={25}
|
step={25}
|
||||||
min={25}
|
min={0}
|
||||||
max={500}
|
max={500}
|
||||||
valueLabelDisplay="auto"
|
valueLabelDisplay="auto"
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user