Exemplo n.º 1
0
 public function onTimer()
 {
     if (END_TIME - 1 < time()) {
         $this->close();
         LockUtil::removeLock('wotapipserver');
         die('timelimit!:' . (microtime(true) - END_TIME - 1));
     }
 }
 /**
  * Switches between two modes: the impact and the return 'mode'.
  * 
  * @param	array	event data
  */
 public function execute($data)
 {
     // TODO: remove this passage?
     // lock management
     echo "l";
     do {
         try {
             LockUtil::checkLock($this->ownerID);
             LockUtil::checkLock($this->ofiaraID);
             // everything checked
             break;
         } catch (SystemException $e) {
             echo 'waiting 0.5s because of a lock ...';
             usleep(500000);
         }
     } while (true);
     echo "m";
     LockUtil::setLock($this->ownerID, 10);
     if ($this->ofiaraID) {
         LockUtil::setLock($this->ofiaraID, 10);
     }
     // execute
     $this->initArrays();
     $this->eventData = $data;
     // return
     if ($data['state'] == 1) {
         if (count($this->fleet)) {
             $this->executeReturn();
             $this->sendReturnMessage();
         }
     } else {
         if ($data['state'] == 0) {
             $this->executeImpact();
             $this->sendImpactOwnerMessage();
             $this->sendImpactOfiaraMessage();
         } else {
             $this->executeUnknownEvent();
         }
     }
     // TODO: integrate this in wcf event listener?
     FleetOvent::update($this);
     // lock management
     LockUtil::removeLock($this->ownerID);
     LockUtil::removeLock($this->ofiaraID);
     return;
 }
 /**
  * Removes the lock.
  */
 protected function removeLock()
 {
     if (!$this->removedLock) {
         LockUtil::removeLock(self::LOCK_NAME);
         $this->removedLock = true;
     }
 }
Exemplo n.º 4
0
}
// check lock
require_once LW_DIR . 'lib/util/LockUtil.class.php';
do {
    $locked = false;
    // check
    try {
        LockUtil::checkLock('wotapipserver');
    } catch (SystemException $e) {
        echo 'l';
        $locked = true;
        // wait 0.05s
        usleep(50000);
        // remove if waiting 15s already
        if (time() - TIME_NOW > 15) {
            LockUtil::removeLock('wotapipserver');
            echo 'removed lock';
        }
    }
} while ($locked);
LockUtil::setLock('wotapipserver', END_TIME + 5);
// load
require_once LW_DIR . 'lib/system/io/socket/WOTAPIServer.class.php';
require_once LW_DIR . 'lib/system/io/socket/WOTAPIServerClient.class.php';
require_once WCF_DIR . 'lib/system/io/socket/SocketDaemon.class.php';
if (!defined('WOTAPI_PORT')) {
    define('WOTAPI_PORT', 57154);
}
if (!defined('CRYPTER_KEY')) {
    define('CRYPTER_KEY', base64_decode('SAG ICH NICHT'));
}
Exemplo n.º 5
0
// include basic ugamela files
include $ugamela_root_path . 'includes/debug.class.' . $phpEx;
$debug = new debug();
include $ugamela_root_path . 'includes/constants.' . $phpEx;
include $ugamela_root_path . 'includes/functions.' . $phpEx;
include $ugamela_root_path . 'includes/vars.' . $phpEx;
include $ugamela_root_path . 'includes/db.' . $phpEx;
if (!defined('NO_PLANET_MAKER')) {
    include $ugamela_root_path . 'includes/planet_maker.' . $phpEx;
}
include $ugamela_root_path . 'includes/rank_maker.' . $phpEx;
include $ugamela_root_path . 'includes/strings.' . $phpEx;
include $ugamela_root_path . "language/" . DEFAULT_LANG . "/lang_info.cfg";
// load config
$result = WCF::getDB()->sendQuery("SELECT * FROM ugml_config");
while ($row = WCF::getDB()->fetchArray($result)) {
    $game_config[$row['config_name']] = $row['config_value'];
}
// calc resources/check hangar production
if (WCF::getUser()->userID) {
    LWCore::getPlanet()->calculateResources();
    //auto logout if ip differs or last onlinetime 12 hours past
    /*if(WCF::getUser()->onlinetime+60*60*12 <= TIME_NOW) {
    		LWCore::logout();
    		die('<meta http-equiv="Refresh" content="1; URL=index.htm"><script>javascript:top.location.href="index.htm"</script>');
    	}*/
}
// global locking
if ($userID > 0) {
    LockUtil::removeLock('global_' . $userID);
}
Exemplo n.º 6
0
 /**
  * Inserts the fleet
  */
 public function fire()
 {
     LockUtil::checkLock(WCF::getUser()->userID);
     LockUtil::setLock(WCF::getUser()->userID, 10);
     EventHandler::fireAction($this, 'shouldFire');
     $this->fleetEditor = FleetEditor::create($this->startPlanetID, $this->endPlanetID, $this->ships, $this->galaxy, $this->system, $this->planet, $this->metal, $this->crystal, $this->deuterium, $this->getDuration(), $this->missionID);
     $planet = Planet::getInstance($this->startPlanetID);
     $planet->getEditor()->changeResources(-$this->metal, -$this->crystal, -($this->deuterium + $this->getConsumption()));
     $ships = array();
     foreach ($this->ships as $specID => $shipCount) {
         $ships[$specID] = -$shipCount;
     }
     $planet->getEditor()->changeLevel($ships);
     // TODO: integrate in wcf eventlistener didFire@FleetQueue
     if ($this->missionID == 11) {
         $formation = new NavalFormation($this->formationID);
         $formation->getEditor()->addFleet($this->fleetEditor->fleetID);
     }
     if ($this->missionID == 12) {
         $standByTime = intval(@$_REQUEST['standByTime']);
         $wakeUpTime = $this->fleetEditor->impactTime + $standByTime;
         $newReturnTime = $this->fleetEditor->returnTime + $standByTime;
         $this->fleetEditor->changeTime(array('return' => $newReturnTime));
         $wakeUpEvent = WOTEventEditor::create(1, $this->fleetEditor->fleetID, array('state' => 2), $wakeUpTime);
         $this->fleetEditor->update(array('wakeUpEventID' => $wakeUpEvent->eventID, 'wakeUpTime' => $wakeUpTime));
     }
     if (WCF::getUser()->userID == 1) {
         FleetOvent::create($this->fleetEditor, false, true);
     }
     EventHandler::fireAction($this, 'didFire');
     $this->deleteFleetQueue();
     LockUtil::removeLock(WCF::getUser()->userID);
 }