Ejemplo n.º 1
0
 /**
  * @see Page::readData
  */
 public function readData()
 {
     parent::readData();
     //echo ".";
     $this->fleetQueue = new FleetQueue(0);
     $this->readTarget();
     $this->specs = Spec::getBySpecType(3);
     $this->fleets = Fleet::getByUserID(WCF::getUser()->userID);
     foreach ($this->fleets as $fleetID => $fleet) {
         $this->fleets[$fleetID]->navalFormation = NavalFormation::getByFleetID($fleetID);
     }
     // backlink
     if (isset($_REQUEST['backlink'])) {
         $this->backlink = StringUtil::trim($_REQUEST['backlink']);
     }
     $array = array();
     preg_match('/^(https?:\\/\\/[^\\/]*\\/)?(.*)$/i', $this->backlink, $array);
     $this->fleetQueue->backlink = $this->backlink = isset($array[2]) ? $array[2] : '';
     //echo ".";
     // TODO: clean this one up
     $sql = "DELETE FROM ugml_galactic_jump_queue\n\t\t\t\tWHERE userID = " . WCF::getUser()->userID;
     WCF::getDB()->registerShutdownUpdate($sql);
     $sql = "INSERT INTO ugml_galactic_jump_queue (userID, startPlanetID, state, time)\n\t\t\t\tVALUES(" . WCF::getUser()->userID . ", " . LWCore::getPlanet()->planetID . ", 1, " . TIME_NOW . ")";
     WCF::getDB()->registerShutdownUpdate($sql);
 }
Ejemplo n.º 2
0
 /**
  * Adds a fleet to the naval formation.
  * 
  * @param	int		fleet id
  */
 public function addFleet($fleetID)
 {
     if (NavalFormation::getByFleetID($fleetID) !== null) {
         return;
     }
     $fleet = Fleet::getInstance($fleetID);
     // impact calculation
     $currentImpactDiff = $this->impactTime - microtime(true);
     $correctureDiff = $fleet->impactTime - microtime(true);
     $duration = $fleet->returnTime - $this->impactTime;
     // correct impact time of formation
     if ($correctureDiff > $currentImpactDiff) {
         $this->impactTime = $fleet->impactTime;
         foreach ($this->fleets as $ifleetID => $ifleet) {
             $addition = $this->impactTime - $ifleet->impactTime;
             $ifleet->getEditor()->changeTime($addition);
         }
         $sql = "UPDATE ugml_naval_formation\n\t\t\t\t\tSET ugml_naval_formation.impactTime = " . $this->impactTime . "\n\t\t\t\t\tWHERE ugml_naval_formation.formationID = " . $this->formationID;
         WCF::getDB()->sendQuery($sql);
     } else {
         $addition = $this->impactTime - $fleet->impactTime;
         $fleet->getEditor()->changeTime($addition);
     }
     $fleet->getEditor()->update(array('missionID' => 11, 'formationID' => $this->formationID));
 }
Ejemplo n.º 3
0
 /**
  * Cancels this flight.
  */
 public function cancel()
 {
     // delete events
     $eventIDsStr = "";
     $data = $this->getData();
     foreach ($data as $key => $eventID) {
         if (strpos($key, 'EventID') !== false && $key !== 'returnEventID' && $eventID != 0) {
             if (!empty($eventIDsStr)) {
                 $eventIDsStr .= ",";
             }
             $eventIDsStr .= $eventID;
         }
     }
     if (empty($eventIDsStr)) {
         return;
     }
     WOTEventEditor::deleteEvents($eventIDsStr);
     // calc flown time
     $returnTime = $this->getCancelDuration() + microtime(true);
     $returnEvent = new WOTEventEditor($this->returnEventID);
     $returnEvent->changeTime($returnTime);
     $this->update(array('impactTime' => 0, 'returnTime' => $returnTime));
     EventHandler::fireAction($this, 'cancel');
     // TODO: integrate this in wcf eventhandler cancel@FleetEditor
     if ($this->missionID == 11) {
         NavalFormation::getByFleetID($this->fleetID)->cancelFleet($this->fleetID);
     }
     // TODO: integrate this in wcf eventhandler cancel@FleetEditor
     if ($this->missionID == 12) {
         $this->update('wakeUpTime', 0);
     }
     FleetLog::update($this->getObject());
 }