Change lastServer to reference the server ip

Should fix issue with newly saved scripts failing to run
This commit is contained in:
Snarling 2021-08-23 06:21:05 -04:00 committed by danielyxie
parent 4278191b0e
commit 386f8a11c5

@ -23,7 +23,7 @@ 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 { GetServerByHostname } from "../../Server/ServerHelpers"; import { getServer } from "../../Server/ServerHelpers";
import { import {
iTutorialNextStep, iTutorialNextStep,
ITutorial, ITutorial,
@ -91,7 +91,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().hostname; lastServer = props.player.getCurrentServer().ip;
lastFilename = props.filename; lastFilename = props.filename;
lastCode = props.code; lastCode = props.code;
lastPosition = null; lastPosition = null;
@ -122,7 +122,7 @@ export function Root(props: IProps): React.ReactElement {
} }
//Save the script //Save the script
const server = GetServerByHostname(lastServer); const server = getServer(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) {
@ -150,7 +150,7 @@ export function Root(props: IProps): React.ReactElement {
return; return;
} }
const server = GetServerByHostname(lastServer); const server = getServer(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 {