/** * Recalculate all scores for one site. * @param WC_Site $site * @return boolean */ public static function calcSite(WC_Site $site) { $regats = self::table(__CLASS__); $siteid = $site->getVar('site_id'); $maxscore = $site->getVar('site_maxscore'); $sitescore = $site->getVar('site_score'); # Clamp to max // $regats->update("regat_onsitescore={$maxscore}", "regat_onsitescore>{$maxscore} and regat_sid={$siteid}"); if ($site->isLinear()) { if ($site->isNoV1()) { self::calcLinearSite($site); } if (false === $regats->update("regat_solved=regat_onsitescore/{$maxscore}, regat_score=regat_onsitescore", "regat_sid={$siteid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } elseif (defined('WECHALL_CAESUM_PATCH')) { # Ceasum Patch $challcount = $site->getVar('site_challcount'); $powarg = $site->getPowArg(); if (false === $regats->update("regat_solved=regat_onsitescore/{$maxscore}, regat_score=POW((regat_onsitescore/{$maxscore}),(1+({$powarg}/{$challcount})))*{$sitescore} ", "regat_sid={$siteid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } else { # Original Code if (false === $regats->update("regat_solved=regat_onsitescore/{$maxscore}, regat_score=(regat_onsitescore/{$maxscore})*(regat_onsitescore/{$maxscore})*{$sitescore} ", "regat_sid={$siteid}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } return false; }