diff --git a/src/NetscriptFunctions/Infiltration.ts b/src/NetscriptFunctions/Infiltration.ts index 4f16b2c03..de1baf14f 100644 --- a/src/NetscriptFunctions/Infiltration.ts +++ b/src/NetscriptFunctions/Infiltration.ts @@ -13,7 +13,7 @@ import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper"; import { checkEnum } from "../utils/helpers/enum"; import { LocationName } from "../Enums"; import { helpers } from "../Netscript/NetscriptHelpers"; -import { FilterTruthy } from "../utils/helpers/ArrayHelpers"; +import { filterTruthy } from "../utils/helpers/ArrayHelpers"; export function NetscriptInfiltration(): InternalAPI { const getLocationsWithInfiltrations = Object.values(Locations).filter( @@ -42,7 +42,7 @@ export function NetscriptInfiltration(): InternalAPI { }; return { getPossibleLocations: () => () => { - return FilterTruthy( + return filterTruthy( getLocationsWithInfiltrations.map((l) => { if (!l.city) return false; return { diff --git a/src/Script/Script.ts b/src/Script/Script.ts index 26df126af..a8786e52b 100644 --- a/src/Script/Script.ts +++ b/src/Script/Script.ts @@ -75,19 +75,6 @@ export class Script implements ContentFile { this.dependencies = new Map(); } - /** - * Save a script from the script editor - * @param filename The new filepath for this Script - * @param code The unformatted code to save - * @param hostname The server to save the script to - */ - saveScript(filename: ScriptFilePath, code: string, hostname: string): void { - this.code = code; - this.invalidateModule(); - this.filename = filename; - this.server = hostname; - } - /** Gets the ram usage, while also attempting to update it if it's currently null */ getRamUsage(otherScripts: Map): number | null { if (this.ramUsage) return this.ramUsage; diff --git a/src/data/codingcontracttypes.ts b/src/data/codingcontracttypes.ts index b4ad6c181..bccb02e67 100644 --- a/src/data/codingcontracttypes.ts +++ b/src/data/codingcontracttypes.ts @@ -3,6 +3,7 @@ import { MinHeap } from "../utils/Heap"; import { comprGenChar, comprLZGenerate, comprLZEncode, comprLZDecode } from "../utils/CompressionContracts"; import { HammingEncode, HammingDecode, HammingEncodeProperly } from "../utils/HammingCodeTools"; +import { filterTruthy } from "../utils/helpers/ArrayHelpers"; /* Function that generates a valid 'data' for a contract type */ export type GeneratorFunc = () => unknown; @@ -1258,7 +1259,8 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [ } const sanitizedPlayerAns: string = removeBracketsFromArrayString(ans); - const sanitizedPlayerAnsArr: string[] = sanitizedPlayerAns.split(","); + // Don't include any "" entries in the parsed array + const sanitizedPlayerAnsArr: string[] = filterTruthy(sanitizedPlayerAns.split(",")); for (let i = 0; i < sanitizedPlayerAnsArr.length; ++i) { sanitizedPlayerAnsArr[i] = removeQuotesFromString(sanitizedPlayerAnsArr[i]).replace(/\s/g, ""); } diff --git a/src/utils/helpers/ArrayHelpers.ts b/src/utils/helpers/ArrayHelpers.ts index a91d0401b..ce6e35a2d 100644 --- a/src/utils/helpers/ArrayHelpers.ts +++ b/src/utils/helpers/ArrayHelpers.ts @@ -22,6 +22,6 @@ export function arrayToString(a: unknown[]): string { return `[${vals.join(", ")}]`; } -export function FilterTruthy(input: T[]): Truthy[] { +export function filterTruthy(input: T[]): Truthy[] { return input.filter(Boolean) as Truthy[]; } diff --git a/src/utils/v2APIBreak.ts b/src/utils/v2APIBreak.ts index 77d364cfc..2b2897c15 100644 --- a/src/utils/v2APIBreak.ts +++ b/src/utils/v2APIBreak.ts @@ -227,9 +227,8 @@ export const v2APIBreak = () => { offenders: [], }); } - - // API break function is called before the version31 2.3.0 changes, scripts are still an array. - for (const script of home.scripts.values() as unknown as Script[]) { + // V31/2.3.0 conversion of scripts to map has already occurred. + for (const script of home.scripts.values()) { processScript(rules, script); }