mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Fix UpdateComponents logic for pathfinding following d592bf9cb6
Followingd592bf9cb6, paths requested at turn N were set-up to be computed between the end of turn N and the start of turn N+1 (which would ultimately allow threading this computation), via calls to 'StartProcessingMoves' and 'FetchAsyncResultsAndSendMessages'. However, the call to UpdateGrid() remained at the start of turn N+1, between the 'start' and 'fetch' calls. Since all paths are currently computed on the 'start' call, this means all paths are computed on a (possibly) dirty pathfinder grid. In particular, this leads to OOS on rejoin since the rejoiner will recompute the grid before computing the outstanding paths. This would also obviously be buggy in a threaded environment, since some paths might be computed on the fresh and some on the dirty grid. Finally, MT_TurnStart was sent before the paths were computed, which might lead to further pathfinder grid changes (not a crashing problem without threading, but still conceptually odd). The 'fetch' call is thus moved before it. This thus fixes d592bf9cb6/D1918, after92ad6a61faalready fixed a first issue. Since the grid is now only updated at the end of a turn, we need to ensure that it is correct on Turn 0, thus the pathfinder recomputes it on InitGame. Refs D14 Reported by: Itms Fixes #5851 Differential Revision: https://code.wildfiregames.com/D3064 This was SVN commit r24142.
This commit is contained in:
@@ -531,19 +531,16 @@ void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengt
|
||||
|
||||
CComponentManager& componentManager = simContext.GetComponentManager();
|
||||
|
||||
CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY);
|
||||
if (cmpPathfinder)
|
||||
cmpPathfinder->FetchAsyncResultsAndSendMessages();
|
||||
|
||||
{
|
||||
PROFILE2("Sim - Update Start");
|
||||
CMessageTurnStart msgTurnStart;
|
||||
componentManager.BroadcastMessage(msgTurnStart);
|
||||
}
|
||||
|
||||
CmpPtr<ICmpPathfinder> cmpPathfinder(simContext, SYSTEM_ENTITY);
|
||||
if (cmpPathfinder)
|
||||
{
|
||||
cmpPathfinder->FetchAsyncResultsAndSendMessages();
|
||||
cmpPathfinder->UpdateGrid();
|
||||
}
|
||||
|
||||
// Push AI commands onto the queue before we use them
|
||||
CmpPtr<ICmpAIManager> cmpAIManager(simContext, SYSTEM_ENTITY);
|
||||
if (cmpAIManager)
|
||||
@@ -594,7 +591,10 @@ void CSimulation2Impl::UpdateComponents(CSimContext& simContext, fixed turnLengt
|
||||
|
||||
// Process all remaining moves
|
||||
if (cmpPathfinder)
|
||||
{
|
||||
cmpPathfinder->UpdateGrid();
|
||||
cmpPathfinder->StartProcessingMoves(false);
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulation2Impl::Interpolate(float simFrameLength, float frameOffset, float realFrameLength)
|
||||
|
||||
Reference in New Issue
Block a user