mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 08:03:48 +01:00
Update Root.tsx
Removed unnecessary conversions between server and ip
This commit is contained in:
parent
386f8a11c5
commit
1a8b194341
@ -23,7 +23,6 @@ import { libSource } from "../NetscriptDefinitions";
|
|||||||
import { NetscriptFunctions } from "../../NetscriptFunctions";
|
import { NetscriptFunctions } from "../../NetscriptFunctions";
|
||||||
import { WorkerScript } from "../../Netscript/WorkerScript";
|
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||||
import { Settings } from "../../Settings/Settings";
|
import { Settings } from "../../Settings/Settings";
|
||||||
import { getServer } from "../../Server/ServerHelpers";
|
|
||||||
import {
|
import {
|
||||||
iTutorialNextStep,
|
iTutorialNextStep,
|
||||||
ITutorial,
|
ITutorial,
|
||||||
@ -91,7 +90,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(props.filename === "") return;
|
if(props.filename === "") return;
|
||||||
if(lastFilename === "")
|
if(lastFilename === "")
|
||||||
lastServer = props.player.getCurrentServer().ip;
|
lastServer = props.player.getCurrentServer();
|
||||||
lastFilename = props.filename;
|
lastFilename = props.filename;
|
||||||
lastCode = props.code;
|
lastCode = props.code;
|
||||||
lastPosition = null;
|
lastPosition = null;
|
||||||
@ -122,11 +121,11 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Save the script
|
//Save the script
|
||||||
const server = getServer(lastServer);
|
const server = lastServer;
|
||||||
if(server === null) throw new Error('Server should not be null but it is.');
|
if(server === null) throw new Error('Server should not be null but it is.');
|
||||||
for (let i = 0; i < server.scripts.length; i++) {
|
for (let i = 0; i < server.scripts.length; i++) {
|
||||||
if (filename == server.scripts[i].filename) {
|
if (filename == server.scripts[i].filename) {
|
||||||
server.scripts[i].saveScript(code, lastServer, server.scripts);
|
server.scripts[i].saveScript(code, lastServer.ip, server.scripts);
|
||||||
props.engine.loadTerminalContent();
|
props.engine.loadTerminalContent();
|
||||||
return iTutorialNextStep();
|
return iTutorialNextStep();
|
||||||
}
|
}
|
||||||
@ -134,7 +133,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
// If the current script does NOT exist, create a new one
|
// If the current script does NOT exist, create a new one
|
||||||
const script = new Script();
|
const script = new Script();
|
||||||
script.saveScript(code, lastServer, server.scripts);
|
script.saveScript(code, lastServer.ip, server.scripts);
|
||||||
server.scripts.push(script);
|
server.scripts.push(script);
|
||||||
|
|
||||||
return iTutorialNextStep();
|
return iTutorialNextStep();
|
||||||
@ -150,7 +149,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = getServer(lastServer);
|
const server = lastServer;
|
||||||
if(server === null) throw new Error('Server should not be null but it is.');
|
if(server === null) throw new Error('Server should not be null but it is.');
|
||||||
if (filename === ".fconf") {
|
if (filename === ".fconf") {
|
||||||
try {
|
try {
|
||||||
@ -163,7 +162,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
//If the current script already exists on the server, overwrite it
|
//If the current script already exists on the server, overwrite it
|
||||||
for (let i = 0; i < server.scripts.length; i++) {
|
for (let i = 0; i < server.scripts.length; i++) {
|
||||||
if (filename == server.scripts[i].filename) {
|
if (filename == server.scripts[i].filename) {
|
||||||
server.scripts[i].saveScript(code, lastServer, server.scripts);
|
server.scripts[i].saveScript(code, lastServer.ip, server.scripts);
|
||||||
props.engine.loadTerminalContent();
|
props.engine.loadTerminalContent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -171,7 +170,7 @@ export function Root(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
//If the current script does NOT exist, create a new one
|
//If the current script does NOT exist, create a new one
|
||||||
const script = new Script();
|
const script = new Script();
|
||||||
script.saveScript(code, lastServer, server.scripts);
|
script.saveScript(code, lastServer.ip, server.scripts);
|
||||||
server.scripts.push(script);
|
server.scripts.push(script);
|
||||||
} else if (filename.endsWith(".txt")) {
|
} else if (filename.endsWith(".txt")) {
|
||||||
for (let i = 0; i < server.textFiles.length; ++i) {
|
for (let i = 0; i < server.textFiles.length; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user