More hotfix

* Fix empty solution for all valid math expressions
This commit is contained in:
omuretsu
2023-05-28 05:25:09 -04:00
parent 8e4492685d
commit ae8f26f03b
5 changed files with 8 additions and 20 deletions

View File

@ -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<IInfiltration> {
const getLocationsWithInfiltrations = Object.values(Locations).filter(
@ -42,7 +42,7 @@ export function NetscriptInfiltration(): InternalAPI<IInfiltration> {
};
return {
getPossibleLocations: () => () => {
return FilterTruthy(
return filterTruthy(
getLocationsWithInfiltrations.map((l) => {
if (!l.city) return false;
return {

View File

@ -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<ScriptFilePath, Script>): number | null {
if (this.ramUsage) return this.ramUsage;

View File

@ -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, "");
}

View File

@ -22,6 +22,6 @@ export function arrayToString(a: unknown[]): string {
return `[${vals.join(", ")}]`;
}
export function FilterTruthy<T>(input: T[]): Truthy<T>[] {
export function filterTruthy<T>(input: T[]): Truthy<T>[] {
return input.filter(Boolean) as Truthy<T>[];
}

View File

@ -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);
}