void BotControl::Think (void) { // this function calls think () function for all available at call moment bots, and // try to catch internal error if such shit occurs float thinkFps = yb_thinkfps.GetFloat (); // check ranges if (thinkFps <= 0.0f || thinkFps > 40.0f) { thinkFps = 22.0f; AddLogEntry (true, LOG_ERROR, "Value of yb_thinkfps should be greater than zero and lower than 40."); yb_thinkfps.SetFloat (thinkFps); } thinkFps = (1.0f / thinkFps) * 0.88f; for (int i = 0; i < engine->GetMaxClients (); i++) { if (m_bots[i] != null) { if (m_bots[i]->m_thinkTimer <= engine->GetTime ()) { // use these try-catch blocks to prevent server crashes when error occurs #if !defined (NDEBUG) && !defined (_DEBUG) try { m_bots[i]->Think (); } catch (...) { // error occurred. kick off all bots and then print a warning message RemoveAll (); ServerPrintNoTag ("**** INTERNAL BOT ERROR! PLEASE SHUTDOWN AND RESTART YOUR SERVER! ****"); } #else m_bots[i]->Think (); #endif m_bots[i]->m_thinkTimer = engine->GetTime () + thinkFps; } } } }