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

In multithreaded and multi-player game, the Restart() in OnGameEnd() fails to work #326

Open
monarchBacilluscoli opened this issue Dec 11, 2019 · 0 comments

Comments

@monarchBacilluscoli
Copy link

monarchBacilluscoli commented Dec 11, 2019

The Update() will still return false thus breaks the main loop, although it have called AgentControl()->Restart() in OnGameEnd().
In single player game with a computer, it works fine.
And maybe that is what caused the problem:

static void CallOnStep(Agent* a) {              // 0. Update()->StepAgents()->RunParallel()->[]step_agent()->CallOnStep() 
    ControlInterface* control = a->Control();
    if (!control->IsInGame()) {
        a->OnGameEnd();                         // 1. Ok, it calls OnGameEnd() and my AgentControl()->Restart() will be called soon!
        control->RequestLeaveGame();            // 2. ...OK...That's it
        return;
    }

    ActionInterface* action = a->Actions();
    control->IssueEvents(action->Commands());
    if (action) {
        action->SendActions();
    }

    ActionFeatureLayerInterface* action_feature_layer = a->ActionsFeatureLayer();
    if (action_feature_layer) {
        action_feature_layer->SendActions();
    }
}                                               // 4. Then it will return to Update() and return false, then the main loop breaks and my program exits
}
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

1 participant