Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read property 'destroy' of undefined at CBattleSelectionState.Shutdown #37

Open
csis0247 opened this issue Jun 23, 2018 · 2 comments

Comments

@csis0247
Copy link

I am getting this error occasionally whenever a round has ended, but before printing "round done" to console, and the script has been unable to recover from it.

Uncaught TypeError: Cannot read property 'destroy' of undefined
    at CBattleSelectionState.Shutdown (game.js?v=cQtonveOglA4&l=english:1299)
    at CGame.Update (game.js?v=cQtonveOglA4&l=english:108)
    at t.gApp.ticker.add [as fn] (game.js?v=cQtonveOglA4&l=english:69)
    at t.emit (pixi.min.js?v=.tDHAybGykI1O:16)
    at t.update (pixi.min.js?v=.tDHAybGykI1O:16)
    at Window._tick (pixi.min.js?v=.tDHAybGykI1O:16)
    at <anonymous>:2:491
    at e.string.g.function.c.(/saliengame/play/anonymous function) (eval at exec_fn (:1:107), <anonymous>:52:483)
@csis0247
Copy link
Author

I made some makeshift adjustments to the code, and it has been running for 9 hours without any major issue. There may still be difficulty exiting the planet once it has been conquered, but it is very likely that it is Steam's issue rather than the script's, as I cannot manually leave the planet either, for minutes.

Step 1: Add a global error catching function in an empty space just below the header comments and above the first line of real code "(function() {..." , to allow recovery after the occurrence of the above exception (or in fact any uncatched exception).

window.onerror = function(msg, url, line, col, error) {
    // Basically I copied the original reload method to a "global" level.
    setTimeout(function() {
        if (typeof unsafeWindow !== "undefined")
            unsafeWindow.location.reload();
        else
            window.location.reload();
    }, 750);

    var suppressErrorAlert = true;
    // If you return true, then error alerts (like in older versions of
    // Internet Explorer) will be suppressed.
    return suppressErrorAlert;
};

Step 2: I am not certain if it really is useful. But the rate of error was reduced after I increased the interval of the "loop".

Change all

setInterval(gameCheck, 100)

into

setInterval(gameCheck, 200)

Effectively doubling the timer interval, whatever it does.

Step 3: This change is irrelevant, but I added it to keep track of my progress (score) in the console.

Look for the line:

console.log('Joining zone:', zoneId);

And add the following line below it:

console.log('Current score: ' + gPlayerInfo.score);

@coryshaw1
Copy link
Owner

My only worry with overwriting window.onerror is being able to help users that are saying that they are just constantly refreshing. They could keep "Preserve Log" checked in console, but it adds an extra problem to try support them with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants