Ejemplo n.º 1
0
 public static function getFromId($id)
 {
     $data = Neuron_GameServer_LogSerializer::decode($id);
     $out = new Dolumar_Logable_GeneralContainer();
     foreach ($data as $v) {
         $out->add($v);
     }
     return $out;
 }
Ejemplo n.º 2
0
 private function processTransfers()
 {
     if ($this->areTransfersProcessed) {
         return true;
     }
     $db = Neuron_DB_Database::getInstance();
     $this->areTransfersProcessed = true;
     $transfers = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tvillages_transfers\n\t\t\tWHERE\n\t\t\t\tto_vid = {$this->objMember->getId()} AND\n\t\t\t\tt_date_received < FROM_UNIXTIME(" . NOW . ") AND\n\t\t\t\tt_isReceived = '0'\n\t\t");
     if (count($transfers) > 0) {
         $objLock = Neuron_Core_Lock::__getInstance();
         if ($objLock->setLock('prcTransfer', $this->objMember->getId())) {
             try {
                 // Reload the transfers (lock bestendig)
                 $transfers = $db->query("\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t*\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tvillages_transfers\n\t\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\t\tvillages_transfers_items USING(t_id)\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tto_vid = {$this->objMember->getId()} AND\n\t\t\t\t\t\t\tt_date_received < FROM_UNIXTIME(" . NOW . ") AND\n\t\t\t\t\t\t\tt_isReceived = '0'\n\t\t\t\t\t");
                 $resources = array();
                 $runes = array();
                 $equipment = array();
                 $transactions = array();
                 foreach ($transfers as $v) {
                     switch ($v['ti_type']) {
                         case 'RESOURCE':
                             if (isset($resources[$v['ti_key']])) {
                                 $resources[$v['ti_key']] += $v['ti_amount'];
                             } else {
                                 $resources[$v['ti_key']] = $v['ti_amount'];
                             }
                             break;
                         case 'RUNE':
                             if (isset($runes[$v['ti_key']])) {
                                 $runes[$v['ti_key']] += $v['ti_amount'];
                             } else {
                                 $runes[$v['ti_key']] = $v['ti_amount'];
                             }
                             break;
                         case 'EQUIPMENT':
                             if (isset($equipment[$v['ti_key']])) {
                                 $equipment[$v['ti_key']] += $v['ti_amount'];
                             } else {
                                 $equipment[$v['ti_key']] = $v['ti_amount'];
                             }
                             break;
                     }
                     $transactions[$v['t_id']] = true;
                 }
                 foreach (array_keys($transactions) as $v) {
                     // Now make sure we don't give these resources again
                     $db->query("\n\t\t\t\t\t\t\tUPDATE\n\t\t\t\t\t\t\t\tvillages_transfers\n\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\tt_isReceived = '1'\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tt_id = {$v}\n\t\t\t\t\t\t");
                 }
             } catch (Exception $error) {
                 error_log("Transfer error: " . $error->getMessage());
             }
             $objLock->releaseLock('prcTransfer', $this->objMember->getId());
             $logcontainer = new Dolumar_Logable_GeneralContainer();
             // Now let's add 'em resources
             if (count($resources) > 0) {
                 $logcontainer->add(new Dolumar_Logable_ResourceContainer($resources));
                 $this->giveResources($resources);
             }
             if (count($runes) > 0) {
                 $logcontainer->add(new Dolumar_Logable_RuneContainer($runes));
                 $this->giveRunes($runes);
             }
             if (count($equipment) > 0) {
                 $this->giveEquipment($equipment);
             }
             // Now we just need to log it
             $objLogs = Dolumar_Players_Logs::__getInstance();
             $objLogs->addCompleteTransferLog($this->objMember, $logcontainer);
         } else {
             error_log("Could not lock for transfers: " . $this->objMember->getId());
         }
     }
 }