Blizzard / Blizzard/s2client-api

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

Open
#326 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.7k
Forks
280
PR merge metrics
No merged PRs in 30d

Description

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:
```cpp
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
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.