Fix divide by zero crash in zone lighter

feature/pre-code-move
kaetemi 5 years ago committed by Jan Boon
parent 8d48c8ee74
commit 761770d4eb

@ -1179,36 +1179,43 @@ void CZoneLighter::light (CLandscape &landscape, CZone& output, uint zoneToLight
// Set the thread state
_LastPatchComputed.resize (_ProcessCount);
if (patchCount)
{
// Launch threads
uint process;
for (process=0; process<_ProcessCount; process++)
for (process = 0; process < _ProcessCount; process++)
{
// Last patch
uint lastPatch=firstPatch+patchCountByThread;
uint lastPatch = firstPatch + patchCountByThread;
lastPatch %= patchCount;
// Last patch computed
_LastPatchComputed[process] = firstPatch;
// Create a thread
CLightRunnable *runnable = new CLightRunnable (process, this, &description);
IThread *pThread=IThread::create (runnable);
CLightRunnable *runnable = new CLightRunnable(process, this, &description);
IThread *pThread = IThread::create(runnable);
runnable->Thread = pThread;
// New first patch
firstPatch=lastPatch;
firstPatch = lastPatch;
// Launch
pThread->start();
}
// Wait for others processes
while (_ProcessExited!=_ProcessCount)
while (_ProcessExited != _ProcessCount)
{
nlSleep (1000);
nlSleep(1000);
// Call the progress callback
progress ("Lighting patches", (float)_NumberOfPatchComputed/(float)_PatchInfo.size());
progress("Lighting patches", (float)_NumberOfPatchComputed / (float)_PatchInfo.size());
}
}
else
{
nlwarning("Empty zone");
}
// Reset old thread mask

Loading…
Cancel
Save