Fix #10206: Disable scripts in intro game #10241
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #10206
Motivation / Problem
Using scripts in intro game can cause crashes.
We always said intro should not use scripts or newgrfs, but we only enforced the newgrf part (with broken save error because disabling newgrf in a running game is never a good idea).
Dedicated servers may also crash because of scripts during the load test as it's done in
GM_MENU
(unrelated but it's funny to see the broken save error when starting a dedicated server with-g
and a save containing newgrf)Description
Discard script data on load and skip starting of scripts (like it's done for network games).
As OpenTTD requires a script to be started for
is_ai
companies, prevent using any random ones (that may cause crash by accessing settings) by forcing Dummy AI for intro.And don't show AIDebugWindow when an AI dies in intro (as Dummy AI will instant die).
Limitations
This also solves the crash reported in #9720 but starting scripts before the gamestate is ready is still an issue, and #9745 should handle that when done.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.