Example #1
0
 public static function getFromArea(Dolumar_Underworld_Models_Mission $mission, Neuron_GameServer_Map_Area $area)
 {
     $db = Neuron_DB_Database::getInstance();
     $sx = $area->getCenter()->x() - $area->getRadius();
     $ex = $area->getCenter()->x() + $area->getRadius();
     $sy = $area->getCenter()->y() - $area->getRadius();
     $ey = $area->getCenter()->y() + $area->getRadius();
     $sql = "\n\t\t\tSELECT\n\t\t\t\t*,\n\t\t\t\tUNIX_TIMESTAMP(ua_lastrefresh) AS ua_lastrefresh_timestamp\n\t\t\tFROM\n\t\t\t\tunderworld_armies\n\t\t\tWHERE\n\t\t\t\tua_x >= {$sx} AND ua_x <= {$ex} AND \n\t\t\t\tua_y >= {$sy} AND ua_y <= {$ey} AND\n\t\t\t\tum_id = {$mission->getId()}\n\t\t";
     $data = $db->query($sql);
     return self::getObjectsFromReader($data);
 }
Example #2
0
 /**
  *	Return all display objects that are within $radius
  *	of $location (so basically loading a bubble)
  */
 public function getDisplayObjects(Neuron_GameServer_Map_Area $area)
 {
     $profiler = Neuron_Profiler_Profiler::getInstance();
     // Let's replace this :)
     $out = array();
     $squarePoints = array(array($area->getCenter()->x(), $area->getCenter()->y()));
     $buildingSQL = Dolumar_Map_Map::getBuildingsFromLocations($squarePoints, max($area->getRadius(), 3));
     $objects = array();
     foreach ($buildingSQL as $buildingV) {
         $profiler->start('Initializing building');
         $profiler->start('Fetching building race object');
         $race = Dolumar_Races_Race::getRace($buildingV['race']);
         $profiler->stop();
         $profiler->start('Fetching building object');
         $b = Dolumar_Buildings_Building::getBuilding($buildingV['buildingType'], $race, $buildingV['xas'], $buildingV['yas']);
         $village = Dolumar_Players_Village::getVillage($buildingV['village']);
         $b->setVillage($village);
         $profiler->stop();
         $profiler->start('Setting data');
         $b->setData($buildingV['bid'], $buildingV);
         if ($buildingV['destroyDate'] > 0 && $buildingV['destroyDate'] < NOW) {
             $b->setDestroyed(true);
         }
         $profiler->stop();
         $profiler->start('Assigning building to array');
         //$buildings[floor ($buildingV['xas'])][floor ($buildingV['yas'])][] = $b;
         //$objects[] = new Dolumar_Map_Object ($b);
         list($x, $y) = $b->getLocation();
         $object = new Dolumar_NewMap_Object($b);
         $object->setLocation(new Neuron_GameServer_Map_Location($x, $y));
         $objects[] = $object;
         $profiler->stop();
         $profiler->stop();
     }
     return $objects;
 }