From 4fb1dbf2e3ea8a83a569eee5cf8d5e3522dbd7c8 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sun, 2 Jan 2022 12:13:01 -0500 Subject: [PATCH 01/14] fix some weird eval --- src/NetscriptEvaluator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetscriptEvaluator.ts b/src/NetscriptEvaluator.ts index d5a35b214..dfba570f7 100644 --- a/src/NetscriptEvaluator.ts +++ b/src/NetscriptEvaluator.ts @@ -44,7 +44,7 @@ export function resolveNetscriptRequestedThreads( `Invalid thread count passed to ${functionName}: ${requestedThreads}. Threads must be a positive number.`, ); } - if (requestedThreads > threads) { + if (requestedThreadsAsInt > threads) { throw makeRuntimeRejectMsg( workerScript, `Too many threads requested by ${functionName}. Requested: ${requestedThreads}. Has: ${threads}.`, From f8607ce73e7dc8109bb7dceca5fce795548c7fec Mon Sep 17 00:00:00 2001 From: daan flore Date: Sun, 2 Jan 2022 18:54:11 +0100 Subject: [PATCH 02/14] Adding dorgotten typescript defenitions to file --- src/ScriptEditor/NetscriptDefinitions.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index cfc02ffe9..bcc99cb89 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -5155,6 +5155,7 @@ export interface NS extends Singularity { * * @returns info about a running script */ + getRunningScript(): RunningScript; getRunningScript(filename: string | number, hostname: string, ...args: (string | number)[]): RunningScript; /** From 62c19c9078a9eff3098e212c0f4193e3c31eb4bd Mon Sep 17 00:00:00 2001 From: pan-kuleczka <80748387+pan-kuleczka@users.noreply.github.com> Date: Sun, 2 Jan 2022 18:56:52 +0100 Subject: [PATCH 03/14] hackAnalyze definition fix to match markdown --- src/ScriptEditor/NetscriptDefinitions.d.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 01a405a47..05c44fc67 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4079,31 +4079,28 @@ export interface NS extends Singularity { hackAnalyzeThreads(host: string, hackAmount: number): number; /** - * Get the percent of money stolen with a single thread. + * Get the part of money stolen with a single thread. * @remarks * RAM cost: 1 GB * - * Returns the percentage of the specified server’s money you will steal with a single hack. - * This value is returned in percentage form, not decimal - * (Netscript functions typically return in decimal form, but not this one). - * This percentage is influenced by the player's hacking skill. + * Returns the part of the specified server’s money you will steal with a single thread hack. * * @example * ```ts * // NS1: * //For example, assume the following returns 0.01: * var hackAmount = hackAnalyze("foodnstuff"); - * //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you hack using N threads, then you will steal N*0.01 times its total money. + * //This means that if hack the foodnstuff server using a single thread, then you will steal 1%, or 0.01 of its total money. If you hack using N threads, then you will steal N*0.01 times its total money. * ``` * @example * ```ts * // NS2: * //For example, assume the following returns 0.01: * const hackAmount = ns.hackAnalyze("foodnstuff"); - * //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you hack using N threads, then you will steal N*0.01 times its total money. + * //This means that if hack the foodnstuff server using a single thread, then you will steal 1%, or 0.01 of its total money. If you hack using N threads, then you will steal N*0.01 times its total money. * ``` * @param host - Hostname of the target server. - * @returns The percentage of money you will steal from the target server with a single hack. + * @returns The part of money you will steal from the target server with a single thread hack. */ hackAnalyze(host: string): number; From 74ee7f371dca42ba8e601e5f04cf31d1b570bd00 Mon Sep 17 00:00:00 2001 From: daan flore Date: Sun, 2 Jan 2022 19:24:16 +0100 Subject: [PATCH 04/14] String value should also be possible to write --- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index bcc99cb89..c786bd72e 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -5290,7 +5290,7 @@ export interface NS extends Singularity { * @param data - Data to write. * @param mode - Defines the write mode. Only valid when writing to text files. */ - write(handle: string, data?: string[] | number, mode?: "w" | "a"): Promise; + write(handle: string, data?: string[] | number | string, mode?: "w" | "a"): Promise; /** * Attempt to write to a port. From 3ac26594db452ca34e16ef33016af27e0d917565 Mon Sep 17 00:00:00 2001 From: nickofolas <60761231+nickofolas@users.noreply.github.com> Date: Sun, 2 Jan 2022 13:11:03 -0600 Subject: [PATCH 05/14] Update ns.toast() signature --- dist/bitburner.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/bitburner.d.ts b/dist/bitburner.d.ts index 44ab57d24..e5a4d628b 100644 --- a/dist/bitburner.d.ts +++ b/dist/bitburner.d.ts @@ -3678,8 +3678,9 @@ export declare interface NS extends Singularity { * Queue a toast (bottom-right notification). * @param msg - Message in the toast. * @param variant - Type of toast, must be one of success, info, warning, error. Defaults to success. + * @param duration - Duration of toast in ms, defaults to 2000 */ - toast(msg: any, variant?: string): void; + toast(msg: any, variant?: string, duration?: number): void; /** * Download a file from the internet. From 8c851b577aa3b73910f47cedc4b9263cf7e9ad73 Mon Sep 17 00:00:00 2001 From: daan flore Date: Sun, 2 Jan 2022 20:40:57 +0100 Subject: [PATCH 06/14] Adding correct types at run args command --- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index c786bd72e..52ad9d861 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4560,7 +4560,7 @@ export interface NS extends Singularity { * @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. * @returns Returns the PID of a successfully started script, and 0 otherwise. */ - run(script: string, numThreads?: number, ...args: string[]): number; + run(script: string, numThreads?: number, ...args: Array): number; /** * Start another script on any server. From 5c57bd43f6bcea5884de6b2a4ff38dbba42da2ce Mon Sep 17 00:00:00 2001 From: Kebap Date: Sun, 2 Jan 2022 22:20:45 +0100 Subject: [PATCH 07/14] Mention doing things simultaneously --- ...ettingstartedguideforbeginnerprogrammers.rst | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/source/guidesandtips/gettingstartedguideforbeginnerprogrammers.rst b/doc/source/guidesandtips/gettingstartedguideforbeginnerprogrammers.rst index 314fbf229..571bcec7c 100644 --- a/doc/source/guidesandtips/gettingstartedguideforbeginnerprogrammers.rst +++ b/doc/source/guidesandtips/gettingstartedguideforbeginnerprogrammers.rst @@ -520,10 +520,12 @@ will appear that simply says :code:`Work`. Click this to start working. Working at :code:`Joe's Guns` earns $110 per second and also grants some experience for every stat except hacking. -Working for a company is completely passive. However, you will not be able to do anything -else in the game while you work. You can cancel working at any time. You'll notice that -cancelling your work early causes you to lose out on some reputation gains, but -you shouldn't worry about this. Company reputation isn't important right now. +Working for a company is completely passive. You can choose to focus on your work, do +something else simultaneously, or switch between those two. While you focus on work, +you will not be able to do anything else in the game. If you do something else meanwhile, +you will not gain reputation at the same speed. You can cancel working at any time. +You'll notice that cancelling your work early causes you to lose out on some reputation +gains, but you shouldn't worry about this. Company reputation isn't important right now. Once your hacking hits level 75, you can visit :code:`Carmichael Security` in the city and get a software job there. This job offers higher pay and also earns you @@ -720,9 +722,10 @@ navigation menu, and from there select |CyberSec|. In the middle of the page there should be a button for :code:`Hacking Contracts`. Click it to start earning reputation for the |CyberSec| faction (as well as some hacking experience). The higher your hacking level, the more reputation you -will gain. Note that while you are working for a faction, you cannot interact with -the rest of the game in any way. You can cancel your faction work at any time -with no penalty. +will gain. Note that while you are working for a faction, you can choose to not interact +with the rest of the game in any way to gain reputation at full speed. You can also select to +do something else simultaneously, gaining reputation a bit more slowly, until you focus again. +You can cancel your faction work at any time with no penalty to your reputation gained so far. Purchasing Upgrades and Augmentations ------------------------------------- From 057a2297592f7f7205ab2022548a5cc50228b70a Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 3 Jan 2022 09:31:07 -0500 Subject: [PATCH 08/14] Fix new lines in corp storage tooltip Use react fragments instead of strings so that the
is not escaped. --- src/Corporation/ui/IndustryWarehouse.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Corporation/ui/IndustryWarehouse.tsx b/src/Corporation/ui/IndustryWarehouse.tsx index 5a786fada..a1823eb7b 100644 --- a/src/Corporation/ui/IndustryWarehouse.tsx +++ b/src/Corporation/ui/IndustryWarehouse.tsx @@ -108,26 +108,32 @@ function WarehouseRoot(props: IProps): React.ReactElement { } } - const breakdownItems: string[] = []; + const breakdownItems: JSX.Element[] = []; for (const matName in props.warehouse.materials) { const mat = props.warehouse.materials[matName]; if (!MaterialSizes.hasOwnProperty(matName)) continue; if (mat.qty === 0) continue; - breakdownItems.push(`${matName}: ${numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}`); + breakdownItems.push(<>{matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}); } for (const prodName in division.products) { const prod = division.products[prodName]; if (prod === undefined) continue; - breakdownItems.push(`${prodName}: ${numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}`); + breakdownItems.push(<>{prodName}: {numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}); } - const breakdown = <>{breakdownItems.join('
')} + let breakdown; + if (breakdownItems && breakdownItems.length > 0) { + breakdown = breakdownItems.reduce( + (previous: JSX.Element, current: JSX.Element): JSX.Element => previous && <>{previous}
{current} || <>{current}); + } else { + breakdown = <>No items in storage. + } return ( - {breakdown} : ""}> + <>{breakdown} : ""}> = props.warehouse.size ? "error" : "primary"}> Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "} {numeralWrapper.formatBigNumber(props.warehouse.size)} From 38923af436269b178425d92014264545f42be17f Mon Sep 17 00:00:00 2001 From: Andriy Mykhaylyk Date: Mon, 3 Jan 2022 16:10:22 +0100 Subject: [PATCH 09/14] fix ns.run args type definition --- dist/bitburner.d.ts | 4 ++-- markdown/bitburner.ns.run.md | 4 ++-- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/bitburner.d.ts b/dist/bitburner.d.ts index 44ab57d24..b0c94a0d0 100644 --- a/dist/bitburner.d.ts +++ b/dist/bitburner.d.ts @@ -2720,7 +2720,7 @@ export declare interface NS extends Singularity { * @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. * @returns Returns the PID of a successfully started script, and 0 otherwise. */ - run(script: string, numThreads?: number, ...args: string[]): number; + run(script: string, numThreads?: number, ...args: Array): number; /** * Start another script on any server. @@ -2760,7 +2760,7 @@ export declare interface NS extends Singularity { * @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument numThreads must be filled in with a value. * @returns Returns the PID of a successfully started script, and 0 otherwise. */ - exec(script: string, host: string, numThreads?: number, ...args: string[]): number; + exec(script: string, host: string, numThreads?: number, ...args: Array): number; /** * Terminate current script and start another in 10s. diff --git a/markdown/bitburner.ns.run.md b/markdown/bitburner.ns.run.md index b809f4da8..a7fca9bde 100644 --- a/markdown/bitburner.ns.run.md +++ b/markdown/bitburner.ns.run.md @@ -9,7 +9,7 @@ Start another script on the current server. Signature: ```typescript -run(script: string, numThreads?: number, ...args: string[]): number; +run(script: string, numThreads?: number, ...args: Array): number; ``` ## Parameters @@ -18,7 +18,7 @@ run(script: string, numThreads?: number, ...args: string[]): number; | --- | --- | --- | | script | string | Filename of script to run. | | numThreads | number | Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer. | -| args | string\[\] | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. | +| args | Array | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. | Returns: diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index cfc02ffe9..ea87d96e4 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -4560,7 +4560,7 @@ export interface NS extends Singularity { * @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. * @returns Returns the PID of a successfully started script, and 0 otherwise. */ - run(script: string, numThreads?: number, ...args: string[]): number; + run(script: string, numThreads?: number, ...args: Array): number; /** * Start another script on any server. From bdef14b02922f617de668f585725ac5b237e8b59 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 3 Jan 2022 10:29:56 -0500 Subject: [PATCH 10/14] Add API server information menu item --- electron/gameWindow.js | 6 ++---- electron/menu.js | 26 +++++++++++++++++++++++++- electron/utils.js | 8 +++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/electron/gameWindow.js b/electron/gameWindow.js index 39fdaea0e..f105340f8 100644 --- a/electron/gameWindow.js +++ b/electron/gameWindow.js @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const { app, BrowserWindow, shell } = require("electron"); +const { app, BrowserWindow } = require("electron"); const log = require("electron-log"); const utils = require("./utils"); const achievements = require("./achievements"); @@ -31,9 +31,7 @@ async function createWindow(killall) { // and open every other protocols on the browser e.preventDefault(); - shell.openExternal(url); - - global.app_playerOpenedExternalLink = true; + utils.openExternal(url); }); window.webContents.backgroundThrottling = false; diff --git a/electron/menu.js b/electron/menu.js index 9b73b984c..ac00af758 100644 --- a/electron/menu.js +++ b/electron/menu.js @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const { Menu, clipboard } = require("electron"); +const { Menu, clipboard, dialog } = require("electron"); const log = require("electron-log"); const api = require("./api-server"); const utils = require("./utils"); @@ -78,6 +78,30 @@ function getMenu(window) { clipboard.writeText(token); }) }, + { + type: 'separator', + }, + { + label: 'Information', + click: () => { + dialog.showMessageBox({ + type: 'info', + title: 'Bitburner > API Server Information', + message: 'The API Server is used to write script files to your in-game home.', + detail: 'There is an official Visual Studio Code extension that makes use of that feature.\n\n' + + 'It allows you to write your script file in an external IDE and have them pushed over to the game automatically.\n' + + 'If you want more information, head over to: https://github.com/bitburner-official/bitburner-vscode.', + buttons: ['Dismiss', 'Open Extension Link (GitHub)'], + defaultId: 0, + cancelId: 0, + noLink: true, + }).then(({response}) => { + if (response === 1) { + utils.openExternal('https://github.com/bitburner-official/bitburner-vscode'); + } + }); + } + } ] }, { diff --git a/electron/utils.js b/electron/utils.js index 8e45eba3e..ed88a01f9 100644 --- a/electron/utils.js +++ b/electron/utils.js @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ -const { app, dialog } = require("electron"); +const { app, dialog, shell } = require("electron"); const log = require("electron-log"); const achievements = require("./achievements"); @@ -93,7 +93,13 @@ async function exportSave(window) { .executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true); } +function openExternal(url) { + shell.openExternal(url); + global.app_playerOpenedExternalLink = true; +} + module.exports = { reloadAndKill, showErrorBox, exportSave, attachUnresponsiveAppHandler, detachUnresponsiveAppHandler, + openExternal, } From 6d8df6744ef8f0a21c9d06e477b64ee96a19ac66 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 3 Jan 2022 10:32:01 -0500 Subject: [PATCH 11/14] Add toasts & terminal funcs to electron app Attach functions to the window object so that the wrapper can executeJs to display messages to the player --- electron/menu.js | 15 +++++++++++++++ electron/utils.js | 12 +++++++++++- src/Electron.tsx | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/electron/menu.js b/electron/menu.js index ac00af758..b497c897b 100644 --- a/electron/menu.js +++ b/electron/menu.js @@ -54,12 +54,21 @@ function getMenu(window) { { label: api.isListening() ? 'Disable Server' : 'Enable Server', click: (async () => { + let success = false; try { await api.toggleServer(); + success = true; } catch (error) { log.error(error); utils.showErrorBox('Error Toggling Server', error); } + if (success && api.isListening()) { + utils.writeToast(window, "Started API Server", "success"); + } else if (success && !api.isListening()) { + utils.writeToast(window, "Stopped API Server", "success"); + } else { + utils.writeToast(window, 'Error Toggling Server', "error"); + } refreshMenu(window); }) }, @@ -67,6 +76,11 @@ function getMenu(window) { label: api.isAutostart() ? 'Disable Autostart' : 'Enable Autostart', click: (async () => { api.toggleAutostart(); + if (api.isAutostart()) { + utils.writeToast(window, "Enabled API Server Autostart", "success"); + } else { + utils.writeToast(window, "Disabled API Server Autostart", "success"); + } refreshMenu(window); }) }, @@ -76,6 +90,7 @@ function getMenu(window) { const token = api.getAuthenticationToken(); log.log('Wrote authentication token to clipboard'); clipboard.writeText(token); + utils.writeToast(window, "Copied Authentication Token to Clipboard", "info"); }) }, { diff --git a/electron/utils.js b/electron/utils.js index ed88a01f9..03175b57b 100644 --- a/electron/utils.js +++ b/electron/utils.js @@ -93,6 +93,16 @@ async function exportSave(window) { .executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true); } +async function writeTerminal(window, message, type = null) { + await window.webContents + .executeJavaScript(`window.appNotifier.terminal("${message}", "${type}");`, true) +} + +async function writeToast(window, message, type = "info", duration = 2000) { + await window.webContents + .executeJavaScript(`window.appNotifier.toast("${message}", "${type}", ${duration});`, true) +} + function openExternal(url) { shell.openExternal(url); global.app_playerOpenedExternalLink = true; @@ -101,5 +111,5 @@ function openExternal(url) { module.exports = { reloadAndKill, showErrorBox, exportSave, attachUnresponsiveAppHandler, detachUnresponsiveAppHandler, - openExternal, + openExternal, writeTerminal, writeToast, } diff --git a/src/Electron.tsx b/src/Electron.tsx index ba2e9866a..9931d3a5e 100644 --- a/src/Electron.tsx +++ b/src/Electron.tsx @@ -22,6 +22,9 @@ import { Server } from "./Server/Server"; import { Router } from "./ui/GameRoot"; import { Page } from "./ui/Router"; import { removeLeadingSlash } from "./Terminal/DirectoryHelpers"; +import { Terminal } from './Terminal'; +import { SnackbarEvents } from "./ui/React/Snackbar"; +import { IMap } from "./types"; interface Achievement { ID: string; @@ -417,6 +420,7 @@ export function initElectron(): void { setAchievements([]); initWebserver(); setInterval(calculateAchievements, 5000); + initAppNotifier(); } function initWebserver(): void { @@ -451,3 +455,27 @@ function initWebserver(): void { return "not a script file"; }; } + +// Expose certain alert functions to allow the wrapper to sends message to the game +function initAppNotifier(): void { + const funcs = { + terminal: (message: string, type?: string) => { + const typesFn: IMap<(s: string) => void> = { + info: Terminal.info, + warn: Terminal.warn, + error: Terminal.error, + success: Terminal.success + }; + let fn; + if (type) fn = typesFn[type]; + if (!fn) fn = Terminal.print; + fn.bind(Terminal)(message); + }, + toast: (message: string, type: "info" | "success" | "warning" | "error" , duration = 2000) => + SnackbarEvents.emit(message, type, duration), + } + + // Will be consumud by the electron wrapper. + // @ts-ignore + window.appNotifier = funcs; +} From 6c3618cb6506c652a6ca42927127f22e5d189772 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 3 Jan 2022 10:33:58 -0500 Subject: [PATCH 12/14] Check userAgent before running electron init --- src/Electron.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Electron.tsx b/src/Electron.tsx index 9931d3a5e..0b71fa94f 100644 --- a/src/Electron.tsx +++ b/src/Electron.tsx @@ -417,10 +417,14 @@ function calculateAchievements(): void { } export function initElectron(): void { - setAchievements([]); - initWebserver(); - setInterval(calculateAchievements, 5000); - initAppNotifier(); + const userAgent = navigator.userAgent.toLowerCase(); + if (userAgent.indexOf(' electron/') > -1) { + // Electron-specific code + setAchievements([]); + initWebserver(); + setInterval(calculateAchievements, 5000); + initAppNotifier(); + } } function initWebserver(): void { From dfabc0ac115f64e1c36da4125d9814a0ae2a173a Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 3 Jan 2022 11:02:29 -0500 Subject: [PATCH 13/14] Fix import save issue with large files The base64 regex was throwing a maximum stack size exceeded error with large files. The whole check was a bit redundant since we already try to parse the file from base64 just below. --- src/ui/React/GameOptionsRoot.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/ui/React/GameOptionsRoot.tsx b/src/ui/React/GameOptionsRoot.tsx index 73b8a364e..e96f8ce41 100644 --- a/src/ui/React/GameOptionsRoot.tsx +++ b/src/ui/React/GameOptionsRoot.tsx @@ -221,13 +221,6 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { } const contents = result; - // https://stackoverflow.com/a/35002237 - const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; - if (!base64regex.test(contents)) { - SnackbarEvents.emit("Save game was not a base64 string", "error", 5000); - return; - } - let newSave; try { newSave = window.atob(contents); @@ -237,7 +230,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { } if (!newSave || newSave === '') { - SnackbarEvents.emit("Save game had not content", "error", 5000); + SnackbarEvents.emit("Save game had not content or was not base64 encoded", "error", 5000); return; } From df37f884eda7ca628e10da0061942488af22b755 Mon Sep 17 00:00:00 2001 From: ApatheticsAnonymous <2817183+ApatheticsAnonymous@users.noreply.github.com> Date: Mon, 3 Jan 2022 14:21:58 -0500 Subject: [PATCH 14/14] Help clarify the behavior of server RAM to executing a script with multiple threads --- doc/source/basicgameplay/servers.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/basicgameplay/servers.rst b/doc/source/basicgameplay/servers.rst index f754ec428..e0f5c8bae 100644 --- a/doc/source/basicgameplay/servers.rst +++ b/doc/source/basicgameplay/servers.rst @@ -13,7 +13,8 @@ Server RAM Perhaps the most important property of a server to make note of is its RAM, which refers to how much memory is available on that machine. RAM is important because it is required to run Scripts. More RAM allows -the user to run more powerful and complicated scripts. +the user to run more powerful and complicated scripts as well as executing +a script with :ref:`more threads `. The `free`, `scan-analyze`, and `analyze` Terminal commands can be used to check how much RAM a server has.