mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 22:22:26 +01:00
Merge pull request #1651 from danielyxie/dev
Add recovery mode in case a save file doesn't load correctly.
This commit is contained in:
commit
bf45dcc734
36
dist/vendor.bundle.js
vendored
36
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -119,11 +119,12 @@ export function Game(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function Progress(): React.ReactElement {
|
||||
console.log(results);
|
||||
return (
|
||||
<h4>
|
||||
<Typography variant="h4">
|
||||
<span style={{ color: "gray" }}>{results.slice(0, results.length - 1)}</span>
|
||||
{results[results.length - 1]}
|
||||
</h4>
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ export function SlashGame(props: IMinigameProps): React.ReactElement {
|
||||
setPhase(2);
|
||||
id = window.setTimeout(() => setPhase(0), difficulty.window);
|
||||
}, 250);
|
||||
}, Math.random() * 3250 + 1500);
|
||||
}, Math.random() * 3250 + 1500 - (250 + difficulty.window));
|
||||
return () => {
|
||||
clearInterval(id);
|
||||
};
|
||||
|
@ -4,7 +4,6 @@ import { sanitizeExploits } from "./Exploits/Exploit";
|
||||
|
||||
import { Reviver } from "./utils/JSONReviver";
|
||||
import Decimal from "decimal.js";
|
||||
import { Programs } from "./Programs/Programs";
|
||||
|
||||
export let Player = new PlayerObject();
|
||||
|
||||
|
91
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
91
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -893,7 +893,7 @@ interface SleeveWorkGains {
|
||||
*/
|
||||
interface SourceFileLvl {
|
||||
/** The number of the source file */
|
||||
n: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
||||
n: number;
|
||||
/** The level of the source file */
|
||||
lvl: number;
|
||||
}
|
||||
@ -2994,7 +2994,7 @@ interface CodingContract {
|
||||
* @remarks 10 GB
|
||||
* @param answer - Solution for the contract.
|
||||
* @param fn - Filename of the contract.
|
||||
* @param host - Host or IP of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param host - Host of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @returns True if the solution was correct, false otherwise.
|
||||
*/
|
||||
attempt(answer: string | string[] | number, fn: string, host?: string): boolean;
|
||||
@ -3005,7 +3005,7 @@ interface CodingContract {
|
||||
* @remarks 10 GB
|
||||
* @param answer - Solution for the contract.
|
||||
* @param fn - Filename of the contract.
|
||||
* @param host - Host or IP of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param host - Host of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param opts - Optional parameters for configuring function behavior.
|
||||
* @returns True if the solution was correct, false otherwise. If the returnReward option is configured, then the function will instead return a string. If the contract is successfully solved, the string will contain a description of the contract’s reward. Otherwise, it will be an empty string.
|
||||
*/
|
||||
@ -3017,7 +3017,7 @@ interface CodingContract {
|
||||
*
|
||||
* @remarks RAM cost: 5 GB
|
||||
* @param fn - Filename of the contract.
|
||||
* @param host - Host or IP of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param host - Host of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @returns Name describing the type of problem posed by the Coding Contract.
|
||||
*/
|
||||
getContractType(fn: string, host?: string): CodingContractTypes;
|
||||
@ -3027,7 +3027,7 @@ interface CodingContract {
|
||||
*
|
||||
* @remarks RAM cost: 5 GB
|
||||
* @param fn - Filename of the contract.
|
||||
* @param host - Host or IP of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param host - Host of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @returns Contract’s text description.
|
||||
*/
|
||||
getDescription(fn: string, host?: string): string;
|
||||
@ -3039,7 +3039,7 @@ interface CodingContract {
|
||||
*
|
||||
* @remarks RAM cost: 5 GB
|
||||
* @param fn - Filename of the contract.
|
||||
* @param host - Host or IP of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param host - Host of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @returns The specified contract’s data;
|
||||
*/
|
||||
getData(fn: string, host?: string): string;
|
||||
@ -3049,7 +3049,7 @@ interface CodingContract {
|
||||
*
|
||||
* @remarks RAM cost: 2 GB
|
||||
* @param fn - Filename of the contract.
|
||||
* @param host - Host or IP of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @param host - Host of the server containing the contract. Optional. Defaults to current server if not provided.
|
||||
* @returns How many attempts are remaining for the contract;
|
||||
*/
|
||||
getNumTriesRemaining(fn: string, host?: string): number;
|
||||
@ -3507,6 +3507,9 @@ export interface NS extends Singularity {
|
||||
readonly args: (string | number)[];
|
||||
|
||||
/**
|
||||
* Steal a servers money.
|
||||
* @remarks
|
||||
* RAM cost: 0.1 GB
|
||||
* Function that is used to try and hack servers to steal money and gain hacking experience.
|
||||
* The runtime for this command depends on your hacking level and the target server’s
|
||||
* security level. In order to hack a server you must first gain root access to that server
|
||||
@ -3521,10 +3524,8 @@ export interface NS extends Singularity {
|
||||
* @example
|
||||
* ```ts
|
||||
* hack("foodnstuff");
|
||||
* hack("10.1.2.3");
|
||||
* hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
||||
* ```
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Hostname of the target server to hack.
|
||||
* @param opts - Optional parameters for configuring function behavior.
|
||||
* @returns The amount of money stolen if the hack is successful, and zero otherwise.
|
||||
@ -3532,6 +3533,9 @@ export interface NS extends Singularity {
|
||||
hack(host: string, opts?: BasicHGWOptions): Promise<number>;
|
||||
|
||||
/**
|
||||
* Spoof money in a servers bank account, increasing the amount available.
|
||||
* @remarks
|
||||
* RAM cost: 0.15 GB
|
||||
* Use your hacking skills to increase the amount of money available on a server.
|
||||
* The runtime for this command depends on your hacking level and the target server’s
|
||||
* security level. When `grow` completes, the money available on a target server will
|
||||
@ -3549,7 +3553,6 @@ export interface NS extends Singularity {
|
||||
* grow("foodnstuff");
|
||||
* grow("foodnstuff", { threads: 5 }); // Only use 5 threads to grow
|
||||
* ```
|
||||
* @remarks RAM cost: 0.15 GB
|
||||
* @param host - Hostname of the target server to grow.
|
||||
* @param opts - Optional parameters for configuring function behavior.
|
||||
* @returns The number by which the money on the server was multiplied for the growth.
|
||||
@ -3557,6 +3560,9 @@ export interface NS extends Singularity {
|
||||
grow(host: string, opts?: BasicHGWOptions): Promise<number>;
|
||||
|
||||
/**
|
||||
* Reduce a server security level.
|
||||
* @remarks
|
||||
* RAM cost: 0.15 GB
|
||||
* Use your hacking skills to attack a server’s security, lowering the server’s security level.
|
||||
* The runtime for this command depends on your hacking level and the target server’s security
|
||||
* level. This function lowers the security level of the target server by 0.05.
|
||||
@ -3570,7 +3576,6 @@ export interface NS extends Singularity {
|
||||
* weaken("foodnstuff");
|
||||
* weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
||||
* ```
|
||||
* @remarks RAM cost: 0.15 GB
|
||||
* @param host - Hostname of the target server to weaken.
|
||||
* @param opts - Optional parameters for configuring function behavior.
|
||||
* @returns The amount by which the target server’s security level was decreased. This is equivalent to 0.05 multiplied by the number of script threads.
|
||||
@ -3578,9 +3583,11 @@ export interface NS extends Singularity {
|
||||
weaken(host: string, opts?: BasicHGWOptions): Promise<number>;
|
||||
|
||||
/**
|
||||
* Predict the effect of weaken.
|
||||
* @remarks
|
||||
* RAM cost: 1 GB
|
||||
* Returns the security decrease that would occur if a weaken with this many threads happened.
|
||||
*
|
||||
* @remarks RAM cost: 1 GB
|
||||
* @param threads - Amount of threads that will be used.
|
||||
* @param cores - Optional. The number of cores of the server that would run weaken.
|
||||
* @returns The security decrease.
|
||||
@ -3588,6 +3595,9 @@ export interface NS extends Singularity {
|
||||
weakenAnalyze(threads: number, cores?: number): number;
|
||||
|
||||
/**
|
||||
* Predict the effect of hack.
|
||||
* @remarks
|
||||
* RAM cost: 1 GB
|
||||
* This function returns the number of script threads you need when running the hack command
|
||||
* to steal the specified amount of money from the target server.
|
||||
* If hackAmount is less than zero or greater than the amount of money available on the server,
|
||||
@ -3601,7 +3611,6 @@ export interface NS extends Singularity {
|
||||
* hackAnalyzeThreads("foodnstuff", 1e6);
|
||||
* //If this function returns 50, this means that if your next hack call is run on a script with 50 threads, it will steal $1m from the foodnstuff server.
|
||||
* ```
|
||||
* @remarks RAM cost: 1 GB
|
||||
* @param host - Hostname of the target server to analyze.
|
||||
* @param hackAmount - Amount of money you want to hack from the server.
|
||||
* @returns The number of threads needed to hack the server for hackAmount money.
|
||||
@ -4058,10 +4067,10 @@ export interface NS extends Singularity {
|
||||
* ```
|
||||
* @remarks RAM cost: 0.6 GB
|
||||
* @param files - Filename or an array of filenames of script/literature files to copy.
|
||||
* @param destination - Host or IP of the destination server, which is the server to which the file will be copied.
|
||||
* @param destination - Host of the destination server, which is the server to which the file will be copied.
|
||||
* @returns True if the script/literature file is successfully copied over and false otherwise. If the files argument is an array then this function will return true if at least one of the files in the array is successfully copied.
|
||||
*/
|
||||
scp(files: string | ReadonlyArray<string>, destination: string): boolean;
|
||||
scp(files: string | string[], destination: string): boolean;
|
||||
|
||||
/**
|
||||
* Copies a script or literature (.lit) file(s) to another server. The files argument can be either a string
|
||||
@ -4080,12 +4089,12 @@ export interface NS extends Singularity {
|
||||
* ```
|
||||
* @remarks RAM cost: 0.6 GB
|
||||
* @param files - Filename or an array of filenames of script/literature files to copy.
|
||||
* @param source - Host or IP of the source server, which is the server from which the file will be copied. This argument is optional and if it’s omitted the source will be the current server.
|
||||
* @param destination - Host or IP of the destination server, which is the server to which the file will be copied.
|
||||
* @param source - Host of the source server, which is the server from which the file will be copied. This argument is optional and if it’s omitted the source will be the current server.
|
||||
* @param destination - Host of the destination server, which is the server to which the file will be copied.
|
||||
* @returns True if the script/literature file is successfully copied over and false otherwise. If the files argument is an array then this function will return true if at least one of the files in the array is successfully copied.
|
||||
*/
|
||||
scp(
|
||||
files: string | ReadonlyArray<string>,
|
||||
files: string | string[],
|
||||
source: string,
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
destination: string,
|
||||
@ -4096,7 +4105,7 @@ export interface NS extends Singularity {
|
||||
* (as strings). The returned array is sorted in alphabetic order.
|
||||
*
|
||||
* @remarks RAM cost: 0.2 GB
|
||||
* @param host - Host or IP of the target server.
|
||||
* @param host - Host of the target server.
|
||||
* @param grep - A substring to search for in the filename.
|
||||
* @returns Array with the filenames of all files on the specified server.
|
||||
*/
|
||||
@ -4117,7 +4126,7 @@ export interface NS extends Singularity {
|
||||
* }
|
||||
* ```
|
||||
* @remarks RAM cost: 0.2 GB
|
||||
* @param host - Host or IP address of the target server. If not specified, it will be the current server’s IP by default.
|
||||
* @param host - Host address of the target server. If not specified, it will be the current server’s IP by default.
|
||||
* @returns Array with general information about all scripts running on the specified target server.
|
||||
*/
|
||||
ps(host?: string): ProcessInfo[];
|
||||
@ -4132,7 +4141,7 @@ export interface NS extends Singularity {
|
||||
* }
|
||||
* ```
|
||||
* @remarks RAM cost: 0.05 GB
|
||||
* @param host - Host or IP of the target server
|
||||
* @param host - Host of the target server
|
||||
* @returns True if player has root access to the specified target server, and false otherwise.
|
||||
*/
|
||||
hasRootAccess(host: string): boolean;
|
||||
@ -4206,7 +4215,7 @@ export interface NS extends Singularity {
|
||||
* getServerMoneyAvailable("home"); //Returns player's money
|
||||
* ```
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server
|
||||
* @param host - Host of target server
|
||||
* @returns Amount of money available on the server.
|
||||
*/
|
||||
getServerMoneyAvailable(host: string): number;
|
||||
@ -4215,7 +4224,7 @@ export interface NS extends Singularity {
|
||||
* Returns the maximum amount of money that can be available on a server.
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns Maximum amount of money available on the server.
|
||||
*/
|
||||
getServerMaxMoney(host: string): number;
|
||||
@ -4229,7 +4238,7 @@ export interface NS extends Singularity {
|
||||
* higher percentage increase from grow.
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns Parameter that affects the percentage by which the server’s money is increased when using the grow function.
|
||||
*/
|
||||
getServerGrowth(host: string): number;
|
||||
@ -4240,7 +4249,7 @@ export interface NS extends Singularity {
|
||||
* (but it can go above 100).
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns Security level of the target server.
|
||||
*/
|
||||
getServerSecurityLevel(host: string): number;
|
||||
@ -4255,7 +4264,7 @@ export interface NS extends Singularity {
|
||||
* installing an Augmentation(s).
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns Base security level of the target server.
|
||||
*/
|
||||
getServerBaseSecurityLevel(host: string): number;
|
||||
@ -4264,7 +4273,7 @@ export interface NS extends Singularity {
|
||||
* Returns the minimum security level of the target server.
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns Minimum security level of the target server.
|
||||
*/
|
||||
getServerMinSecurityLevel(host: string): number;
|
||||
@ -4273,7 +4282,7 @@ export interface NS extends Singularity {
|
||||
* Returns the required hacking level of the target server.
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns The required hacking level of the target server.
|
||||
*/
|
||||
getServerRequiredHackingLevel(host: string): number;
|
||||
@ -4282,7 +4291,7 @@ export interface NS extends Singularity {
|
||||
* Returns the number of open ports required to successfully run NUKE.exe on the specified server.
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns The number of open ports required to successfully run NUKE.exe on the specified server.
|
||||
*/
|
||||
getServerNumPortsRequired(host: string): number;
|
||||
@ -4300,7 +4309,7 @@ export interface NS extends Singularity {
|
||||
* ramUsed = res[1];
|
||||
* ```
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns Array with total and used memory on the specified server.
|
||||
*/
|
||||
getServerRam(host: string): [number, number];
|
||||
@ -4309,7 +4318,7 @@ export interface NS extends Singularity {
|
||||
* Returns a boolean denoting whether or not the specified server exists.
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns True if specified server exists, and false otherwise.
|
||||
*/
|
||||
serverExists(host: string): boolean;
|
||||
@ -4335,7 +4344,7 @@ export interface NS extends Singularity {
|
||||
* ```
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param filename - Filename of file to check.
|
||||
* @param host - Host or IP of target server. This is optional. If it is not specified then the function will use the current server as the target server.
|
||||
* @param host - Host of target server. This is optional. If it is not specified then the function will use the current server as the target server.
|
||||
* @returns True if specified file exists, and false otherwise.
|
||||
*/
|
||||
fileExists(filename: string, host?: string): boolean;
|
||||
@ -4361,7 +4370,7 @@ export interface NS extends Singularity {
|
||||
* ```
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param script - Filename of script to check. This is case-sensitive.
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @param args - Arguments to specify/identify which scripts to search for.
|
||||
* @returns True if specified script is running on the target server, and false otherwise.
|
||||
*/
|
||||
@ -4550,7 +4559,7 @@ export interface NS extends Singularity {
|
||||
*
|
||||
* @remarks RAM cost: 1 GB
|
||||
* @param name - Filename of file to remove. Must include the extension.
|
||||
* @param host - Host or IP Address of the server on which to delete the file. Optional. Defaults to current server.
|
||||
* @param host - Host Address of the server on which to delete the file. Optional. Defaults to current server.
|
||||
* @returns True if it successfully deletes the file, and false otherwise.
|
||||
*/
|
||||
rm(name: string, host?: string): boolean;
|
||||
@ -4574,18 +4583,18 @@ export interface NS extends Singularity {
|
||||
* ```
|
||||
* @remarks RAM cost: 1 GB
|
||||
* @param script - Filename of script to check. This is case-sensitive.
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns True if the specified script is running, and false otherwise.
|
||||
*/
|
||||
scriptRunning(script: string, host: string): boolean;
|
||||
|
||||
/**
|
||||
* Kills all scripts with the specified filename on the target server specified by hostname/ip,
|
||||
* Kills all scripts with the specified filename on the target server specified by hostname,
|
||||
* regardless of arguments.
|
||||
*
|
||||
* @remarks RAM cost: 1 GB
|
||||
* @param script - Filename of script to kill. This is case-sensitive.
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @returns true if one or more scripts were successfully killed, and false if none were.
|
||||
*/
|
||||
scriptKill(script: string, host: string): boolean;
|
||||
@ -4604,7 +4613,7 @@ export interface NS extends Singularity {
|
||||
*
|
||||
* @remarks RAM cost: 0.1 GB
|
||||
* @param script - Filename of script. This is case-sensitive.
|
||||
* @param host - Host or IP of target server the script is located on. This is optional, If it is not specified then the function will se the current server as the target server.
|
||||
* @param host - Host of target server the script is located on. This is optional, If it is not specified then the function will se the current server as the target server.
|
||||
* @returns Amount of RAM required to run the specified script on the target server, and 0 if the script does not exist.
|
||||
*/
|
||||
getScriptRam(script: string, host?: string): number;
|
||||
@ -4614,7 +4623,7 @@ export interface NS extends Singularity {
|
||||
* The function takes in an optional hackLvl parameter that can be specified to see what the hack time would be at different hacking levels.
|
||||
*
|
||||
* @remarks RAM cost: 0.05 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @param hackLvl - Optional hacking level for the calculation. Defaults to player’s current hacking level.
|
||||
* @param intLvl - Optional intelligence level for the calculation. Defaults to player’s current intelligence level. (Intelligence is unlocked after obtaining Source-File 5).
|
||||
* @returns Returns the amount of time in seconds it takes to execute the hack Netscript function. Returns Infinity if called on a Hacknet Server.
|
||||
@ -4626,7 +4635,7 @@ export interface NS extends Singularity {
|
||||
* The function takes in an optional hackLvl parameter that can be specified to see what the grow time would be at different hacking levels.
|
||||
*
|
||||
* @remarks RAM cost: 0.05 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @param hackLvl - Optional hacking level for the calculation. Defaults to player’s current hacking level.
|
||||
* @param intLvl - Optional intelligence level for the calculation. Defaults to player’s current intelligence level. (Intelligence is unlocked after obtaining Source-File 5).
|
||||
* @returns Returns the amount of time in seconds it takes to execute the grow Netscript function. Returns Infinity if called on a Hacknet Server.
|
||||
@ -4638,7 +4647,7 @@ export interface NS extends Singularity {
|
||||
* The function takes in an optional hackLvl parameter that can be specified to see what the weaken time would be at different hacking levels.
|
||||
*
|
||||
* @remarks RAM cost: 0.05 GB
|
||||
* @param host - Host or IP of target server.
|
||||
* @param host - Host of target server.
|
||||
* @param hackLvl - Optional hacking level for the calculation. Defaults to player’s current hacking level.
|
||||
* @param intLvl - Optional intelligence level for the calculation. Defaults to player’s current intelligence level. (Intelligence is unlocked after obtaining Source-File 5).
|
||||
* @returns Returns the amount of time in seconds it takes to execute the grow Netscript function. Returns Infinity if called on a Hacknet Server.
|
||||
|
@ -259,12 +259,14 @@ export function Root(props: IProps): React.ReactElement {
|
||||
function updateCode(newCode?: string): void {
|
||||
if (newCode === undefined) return;
|
||||
lastCode = newCode;
|
||||
if (editorRef.current !== null) {
|
||||
lastPosition = editorRef.current.getPosition();
|
||||
infLoop(newCode);
|
||||
}
|
||||
setCode(newCode);
|
||||
updateRAM(newCode);
|
||||
try {
|
||||
if (editorRef.current !== null) {
|
||||
lastPosition = editorRef.current.getPosition();
|
||||
infLoop(newCode);
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
// calculate it once the first time the file is loaded.
|
||||
|
@ -289,6 +289,5 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
|
||||
Object.assign(Settings.theme, save.theme);
|
||||
delete save.theme;
|
||||
Object.assign(Settings, save);
|
||||
console.log(Settings);
|
||||
},
|
||||
};
|
||||
|
@ -73,6 +73,7 @@ import { InvitationModal } from "../Faction/ui/InvitationModal";
|
||||
|
||||
import { enterBitNode } from "../RedPill";
|
||||
import { Context } from "./Context";
|
||||
import { RecoveryMode, RecoveryRoot } from "./React/RecoveryRoot";
|
||||
|
||||
const htmlLocation = location;
|
||||
|
||||
@ -183,6 +184,7 @@ export let Router: IRouter = {
|
||||
};
|
||||
|
||||
function determineStartPage(player: IPlayer): Page {
|
||||
if (RecoveryMode) return Page.Recovery;
|
||||
if (player.isWorking) return Page.Work;
|
||||
return Page.Terminal;
|
||||
}
|
||||
@ -295,7 +297,9 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
|
||||
<InteractiveTutorialRoot />
|
||||
)}
|
||||
</Overview>
|
||||
{page === Page.BitVerse ? (
|
||||
{page === Page.Recovery ? (
|
||||
<RecoveryRoot router={Router} />
|
||||
) : page === Page.BitVerse ? (
|
||||
<BitverseRoot flume={flume} enter={enterBitNode} quick={quick} />
|
||||
) : page === Page.Infiltration ? (
|
||||
<InfiltrationRoot location={location} />
|
||||
|
@ -14,6 +14,7 @@ import { Engine } from "../engine";
|
||||
import { GameRoot } from "./GameRoot";
|
||||
|
||||
import { CONSTANTS } from "../Constants";
|
||||
import { ActivateRecoveryMode } from "./React/RecoveryRoot";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
@ -39,7 +40,14 @@ export function LoadingScreen(): React.ReactElement {
|
||||
async function doLoad(): Promise<void> {
|
||||
await load()
|
||||
.then((saveString) => {
|
||||
Engine.load(saveString);
|
||||
try {
|
||||
Engine.load(saveString);
|
||||
} catch (err: any) {
|
||||
ActivateRecoveryMode();
|
||||
setLoaded(true);
|
||||
throw err;
|
||||
}
|
||||
|
||||
setLoaded(true);
|
||||
})
|
||||
.catch((reason) => {
|
||||
|
@ -35,7 +35,8 @@ export function Overview({ children }: IProps): React.ReactElement {
|
||||
const [open, setOpen] = useState(true);
|
||||
const classes = useStyles();
|
||||
const router = use.Router();
|
||||
if (router.page() === Page.BitVerse || router.page() === Page.Loading) return <></>;
|
||||
if (router.page() === Page.BitVerse || router.page() === Page.Loading || router.page() === Page.Recovery)
|
||||
return <></>;
|
||||
let icon;
|
||||
if (open) {
|
||||
icon = <VisibilityOffIcon color="primary" />;
|
||||
@ -51,4 +52,4 @@ export function Overview({ children }: IProps): React.ReactElement {
|
||||
</Fab>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
50
src/ui/React/RecoveryRoot.tsx
Normal file
50
src/ui/React/RecoveryRoot.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import React from "react";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Link from "@mui/material/Link";
|
||||
import Button from "@mui/material/Button";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { saveObject } from "../../SaveObject";
|
||||
import { IRouter } from "../Router";
|
||||
|
||||
export let RecoveryMode = false;
|
||||
|
||||
export function ActivateRecoveryMode(): void {
|
||||
RecoveryMode = true;
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
router: IRouter;
|
||||
}
|
||||
|
||||
export function RecoveryRoot({ router }: IProps): React.ReactElement {
|
||||
function recover(): void {
|
||||
RecoveryMode = false;
|
||||
router.toTerminal();
|
||||
}
|
||||
Settings.AutosaveInterval = 0;
|
||||
saveObject.exportGame();
|
||||
return (
|
||||
<>
|
||||
<Typography variant="h3">RECOVERY MODE ACTIVATED</Typography>
|
||||
<Typography>
|
||||
There was an error loading your save file and the game went into recovery mode. In this mode saving is disabled
|
||||
and the game will automatically export your save file (to prevent corruption).
|
||||
</Typography>
|
||||
<Typography>At this point it is recommended to alert a developer.</Typography>
|
||||
<Link href="https://github.com/danielyxie/bitburner/issues/new" target="_blank">
|
||||
<Typography>File an issue on github</Typography>
|
||||
</Link>
|
||||
<Link href="https://www.reddit.com/r/Bitburner/" target="_blank">
|
||||
<Typography>Make a reddit post</Typography>
|
||||
</Link>
|
||||
<Link href="https://discord.gg/TFc3hKD" target="_blank">
|
||||
<Typography>Post in the #bug-report channel on Discord.</Typography>
|
||||
</Link>
|
||||
<Typography>Please include your save file.</Typography>
|
||||
<br />
|
||||
<br />
|
||||
<Typography>You can disable recovery mode now. But chances are the game will not work correctly.</Typography>
|
||||
<Button onClick={recover}>DISABLE RECOVERY MODE</Button>
|
||||
</>
|
||||
);
|
||||
}
|
@ -34,6 +34,7 @@ export enum Page {
|
||||
BladeburnerCinematic,
|
||||
Location,
|
||||
Loading,
|
||||
Recovery,
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user