rendered paste bodyDWORD WINAPI CacheThread(void* pParam)
{
if(!pParam)
return 0;
if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST))
{
sLog.outError("Rognar: !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_LOWEST)) failed. [%u]", GetLastError());
return 0;
}
sLog.outError("Rognar: Cache thread created.");
sLog.outError("Rognar: Start caching. Wait...");
Creature* pCreature = NULL;
int index = 0;
for (index = 0; index < 10000; ++index)
{
pCreature = new Creature(NULL);
pCreature->InitValues();
objmgr.mCreatureObj.push(pCreature);
}
sLog.outError("Rognar: Caching done");
while (!World::m_stopEvent)
{
Sleep(1); //for good another thread working
if(objmgr.mCreatureObj.size() < 1000)
{
for (index = 0; index < 5; ++index)
{
pCreature = new Creature(NULL);
pCreature->InitValues();
objmgr.mCreatureObj.push(pCreature);
}
}
else
Sleep(100);
}
return 0;
}