Esempio n. 1
0
 /**
  * Initialize char/map pair Flux_Athena pair.
  *
  * @param Flux_Connection $connection
  * @param Flux_Config $charMapConfig
  * @param Flux_LoginServer $loginServer
  * @param Flux_CharServer $charServer
  * @param Flux_MapServer $mapServer
  * @access public
  */
 public function __construct(Flux_Config $charMapConfig, Flux_LoginServer $loginServer, Flux_CharServer $charServer, Flux_MapServer $mapServer)
 {
     $this->loginServer = $loginServer;
     $this->charServer = $charServer;
     $this->mapServer = $mapServer;
     $this->loginDatabase = $loginServer->config->getDatabase();
     $this->serverName = $charMapConfig->getServerName();
     $this->maxBaseLevel = (int) $charMapConfig->getMaxBaseLevel();
     $this->expRates = $charMapConfig->getExpRates()->toArray();
     $this->dropRates = $charMapConfig->getDropRates()->toArray();
     $this->isRenewal = (bool) $charMapConfig->getRenewal();
     $this->maxCharSlots = (int) $charMapConfig->getMaxCharSlots();
     $this->dateTimezone = $charMapConfig->getDateTimezone();
     $this->charMapDatabase = $charMapConfig->getDatabase();
     $resetDenyMaps = $charMapConfig->getResetDenyMaps();
     if (!$resetDenyMaps) {
         $this->resetDenyMaps = array('sec_pri');
     } elseif (!is_array($resetDenyMaps)) {
         $this->resetDenyMaps = array($resetDenyMaps);
     } else {
         $this->resetDenyMaps = $resetDenyMaps->toArray();
     }
     // Get WoE times specific in servers config.
     $woeDayTimes = $charMapConfig->getWoeDayTimes();
     if ($woeDayTimes instanceof Flux_Config) {
         $woeDayTimes = $woeDayTimes->toArray();
         foreach ($woeDayTimes as $dayTime) {
             if (!is_array($dayTime) || count($dayTime) < 4) {
                 continue;
             }
             list($sDay, $sTime, $eDay, $eTime) = array_slice($dayTime, 0, 4);
             $sTime = trim($sTime);
             $eTime = trim($eTime);
             if ($sDay < 0 || $sDay > 6 || $eDay < 0 || $eDay > 6 || !preg_match('/^\\d{2}:\\d{2}$/', $sTime) || !preg_match('/^\\d{2}:\\d{2}$/', $eTime)) {
                 continue;
             }
             $this->woeDayTimes[] = array('startingDay' => $sDay, 'startingTime' => $sTime, 'endingDay' => $eDay, 'endingTime' => $eTime);
         }
     }
     // Config used for disallowing access to certain modules during WoE.
     $woeDisallow = $charMapConfig->getWoeDisallow();
     $_tempArray = array();
     $this->woeDisallow = new Flux_Config($_tempArray);
     if ($woeDisallow instanceof Flux_Config) {
         $woeDisallow = $woeDisallow->toArray();
         foreach ($woeDisallow as $disallow) {
             if (array_key_exists('module', $disallow)) {
                 $module = $disallow['module'];
                 if (array_key_exists('action', $disallow)) {
                     $action = $disallow['action'];
                     $this->woeDisallow->set("{$module}.{$action}", true);
                 } else {
                     $this->woeDisallow->set($module, true);
                 }
             }
         }
     }
 }