void Raids::checkRaids() { if(!getRunning()){ uint64_t now = OTSYS_TIME(); for(RaidList::iterator it = raidList.begin(); it != raidList.end(); ++it){ if(now >= (getLastRaidEnd() + (*it)->getMargin())){ if(MAX_RAND_RANGE*CHECK_RAIDS_INTERVAL/(*it)->getInterval() >= (uint32_t)random_range(0, MAX_RAND_RANGE)){ #ifdef __DEBUG_RAID__ char buffer[32]; time_t tmp = time(NULL); formatDate(tmp, buffer); std::cout << buffer << " [Notice] Raids: Starting raid " << (*it)->getName() << std::endl; #endif setRunning(*it); (*it)->startRaid(); break; } } } } checkRaidsEvent = Scheduler::getScheduler().addEvent(createSchedulerTask(CHECK_RAIDS_INTERVAL*1000, boost::bind(&Raids::checkRaids, this))); }
void Raids::checkRaids() { if (!getRunning()) { uint64_t now = OTSYS_TIME(); for (auto it = raidList.begin(); it != raidList.end(); ++it) { if (now >= (getLastRaidEnd() + (*it)->getMargin())) { if (MAX_RAND_RANGE * CHECK_RAIDS_INTERVAL / (*it)->getInterval() >= (uint32_t)uniform_random(0, MAX_RAND_RANGE)) { setRunning(*it); (*it)->startRaid(); if (g_config.getBoolean(ConfigManager::SHUTDOWN_AT_SERVERSAVE)) { raidList.erase(it); } break; } } } } checkRaidsEvent = g_scheduler.addEvent(createSchedulerTask(CHECK_RAIDS_INTERVAL * 1000, boost::bind(&Raids::checkRaids, this))); }
void Raids::checkRaids() { if (!getRunning()) { uint64_t now = OTSYS_TIME(); for (auto it = raidList.begin(); it != raidList.end(); ++it) { Raid* raid = *it; if (now >= (getLastRaidEnd() + raid->getMargin())) { if (MAX_RAND_RANGE * CHECK_RAIDS_INTERVAL / raid->getInterval() >= static_cast<uint32_t>(uniform_random(0, MAX_RAND_RANGE))) { setRunning(raid); raid->startRaid(); if (!raid->canBeRepeated()) { raidList.erase(it); } break; } } } } checkRaidsEvent = g_scheduler.addEvent(createSchedulerTask(CHECK_RAIDS_INTERVAL * 1000, std::bind(&Raids::checkRaids, this))); }