mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-20 16:22:56 +02:00
CORPORATION: Corp changes prior to 2.3 finalization (#503)
This commit is contained in:
+10
-14
@@ -86,11 +86,13 @@ import { cloneDeep, escapeRegExp } from "lodash";
|
||||
import { FactionWorkType } from "./Enums";
|
||||
import numeral from "numeral";
|
||||
import { clearPort, peekPort, portHandle, readPort, tryWritePort, writePort } from "./NetscriptPort";
|
||||
import { FilePath } from "./Paths/FilePath";
|
||||
import { FilePath, resolveFilePath } from "./Paths/FilePath";
|
||||
import { hasScriptExtension } from "./Paths/ScriptFilePath";
|
||||
import { hasTextExtension } from "./Paths/TextFilePath";
|
||||
import { ContentFilePath } from "./Paths/ContentFile";
|
||||
import { LiteratureName } from "./Literature/data/LiteratureNames";
|
||||
import { hasProgramExtension } from "./Paths/ProgramFilePath";
|
||||
import { hasContractExtension } from "./Paths/ContractFilePath";
|
||||
|
||||
export const enums: NSEnums = {
|
||||
CityName,
|
||||
@@ -1104,19 +1106,13 @@ export const ns: InternalAPI<NSFull> = {
|
||||
const filename = helpers.string(ctx, "filename", _filename);
|
||||
const hostname = helpers.string(ctx, "hostname", _hostname);
|
||||
const server = helpers.getServer(ctx, hostname);
|
||||
if (server.scripts.has(filename) || server.textFiles.has(filename)) return true;
|
||||
for (let i = 0; i < server.programs.length; ++i) {
|
||||
if (filename.toLowerCase() == server.programs[i].toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < server.messages.length; ++i) {
|
||||
if (filename.toLowerCase() === server.messages[i].toLowerCase()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
const contract = server.contracts.find((c) => c.fn.toLowerCase() === filename.toLowerCase());
|
||||
if (contract) return true;
|
||||
const path = resolveFilePath(filename, ctx.workerScript.name);
|
||||
if (!path) return false;
|
||||
if (hasScriptExtension(path)) return server.scripts.has(path);
|
||||
if (hasTextExtension(path)) return server.textFiles.has(path);
|
||||
if (hasProgramExtension(path)) return server.programs.includes(path);
|
||||
if (path.endsWith(".lit") || path.endsWith(".msg")) return server.messages.includes(path as any);
|
||||
if (hasContractExtension(path)) return !!server.contracts.find(({ fn }) => fn === path);
|
||||
return false;
|
||||
},
|
||||
isRunning:
|
||||
|
||||
Reference in New Issue
Block a user