Grasscutter icon indicating copy to clipboard operation
Grasscutter copied to clipboard

fix first entering teapot failure

Open pfyy opened this issue 1 year ago • 0 comments

Description

Please carefully read the Contributing note and Code of conduct before making any pull requests.

teapot is using a function call:

Position pos = scene.getScriptManager().getConfig().born_pos;

but config may not be ready when the scene is first loaded using another thread, thus causing a fail

    public SceneScriptManager(Scene scene) {
        ...
        // Create
        new Thread(this::init).start();
    }

    private void init() {
        var meta = ScriptLoader.getSceneMeta(getScene().getId());
        if (meta == null) {
            return;
        }
        this.meta = meta;

        // TEMP
        this.isInit = true;
    }

Issues fixed by this PR

this is a dirty fix that waits 100ms 10 times when failure happens

Type of changes

  • [x] Bug fix
  • [ ] New feature
  • [ ] Enhancement
  • [ ] Documentation

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] My pull request is unique and no other pull requests have been opened for these changes
  • [x] I have read the Contributing note and Code of conduct
  • [x] I am responsible for any copyright issues with my code if it occurs in the future.

pfyy avatar Jul 10 '23 19:07 pfyy