Attempt to fix bladeburner.process() issue

For a certain user, it appears that the engine attempts to route to the
bitverse screen before the router is properly initialized. I could not
reproduce the problem on my side and we were not able to extract his
save game, so this is a blind shot if it'll work or not.
This commit is contained in:
Martin Fournier 2022-03-09 15:44:19 -05:00
parent e80190e687
commit 6588bbb8b1
3 changed files with 6 additions and 0 deletions

@ -1914,6 +1914,9 @@ export class Bladeburner implements IBladeburner {
} }
process(router: IRouter, player: IPlayer): void { process(router: IRouter, player: IPlayer): void {
// Edge race condition when the engine checks the processing counters and attempts to route before the router is initialized.
if (!router.isInitialized) return;
// Edge case condition...if Operation Daedalus is complete trigger the BitNode // Edge case condition...if Operation Daedalus is complete trigger the BitNode
if (router.page() !== Page.BitVerse && this.blackops.hasOwnProperty("Operation Daedalus")) { if (router.page() !== Page.BitVerse && this.blackops.hasOwnProperty("Operation Daedalus")) {
return router.toBitVerse(false, false); return router.toBitVerse(false, false);

@ -111,6 +111,7 @@ const useStyles = makeStyles((theme: Theme) =>
); );
export let Router: IRouter = { export let Router: IRouter = {
isInitialized: false,
page: () => { page: () => {
throw new Error("Router called before initialization"); throw new Error("Router called before initialization");
}, },
@ -266,6 +267,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
} }
Router = { Router = {
isInitialized: true,
page: () => page, page: () => page,
allowRouting: (value: boolean) => setAllowRoutingCalls(value), allowRouting: (value: boolean) => setAllowRoutingCalls(value),
toActiveScripts: () => setPage(Page.ActiveScripts), toActiveScripts: () => setPage(Page.ActiveScripts),

@ -54,6 +54,7 @@ export interface IRouter {
// toMission(): void; // toMission(): void;
// toRedPill(): void; // toRedPill(): void;
// toworkInProgress(): void; // toworkInProgress(): void;
isInitialized: boolean;
page(): Page; page(): Page;
allowRouting(value: boolean): void; allowRouting(value: boolean): void;
toActiveScripts(): void; toActiveScripts(): void;