bool MasterDemonologist5(uint32 i, Spell* s) { Player* p_caster = s->p_caster; Unit* unitTarget = s->GetUnitTarget(); if(!p_caster || !unitTarget) return false; //can't imagine how this talent got to anybody else then a player casting on pet uint32 casted_spell_id = 0 ; uint32 inc_resist_by_level = 0 ; uint32 inc_resist_by_level_spell = 0 ; if(unitTarget->GetEntry() == 416) //in case it is imp casted_spell_id = 23829 ; else if(unitTarget->GetEntry() == 1860) //VoidWalker casted_spell_id = 23844 ; else if(unitTarget->GetEntry() == 1863) //Succubus casted_spell_id = 23836 ; else if(unitTarget->GetEntry() == 417) //Felhunter { casted_spell_id = 0 ; inc_resist_by_level_spell = 23840 ; inc_resist_by_level = 100 ; } else if(unitTarget->GetEntry() == 17252) //Felguard { casted_spell_id = 35706 ; inc_resist_by_level_spell = 23840 ; inc_resist_by_level = 50 ; } if(casted_spell_id) { //for self Spell* sp = sSpellFactoryMgr.NewSpell(p_caster, dbcSpell.LookupEntry(casted_spell_id), true, NULL); SpellCastTargets tgt(p_caster->GetGUID()); sp->prepare(&tgt); //for pet sp = sSpellFactoryMgr.NewSpell(unitTarget, dbcSpell.LookupEntry(casted_spell_id), true, NULL); SpellCastTargets tgt1(unitTarget->GetGUID()); sp->prepare(&tgt1); } if(inc_resist_by_level_spell) { //for self Spell* sp = sSpellFactoryMgr.NewSpell(p_caster, dbcSpell.LookupEntry(inc_resist_by_level_spell), true, NULL); SpellCastTargets tgt(p_caster->GetGUID()); sp->prepare(&tgt); //for pet sp = sSpellFactoryMgr.NewSpell(unitTarget, dbcSpell.LookupEntry(inc_resist_by_level_spell), true, NULL); SpellCastTargets tgt1(unitTarget->GetGUID()); sp->prepare(&tgt1); } return true; }
bool MasterDemonologist2(uint8_t /*effectIndex*/, Spell* s) { Player* p_caster = s->p_caster; Unit* unitTarget = s->GetUnitTarget(); if (!p_caster || !unitTarget) return false; //can't imagine how this talent got to anybody else then a player casting on pet uint32 casted_spell_id = 0; uint32 inc_resist_by_level = 0; uint32 inc_resist_by_level_spell = 0; if (unitTarget->getEntry() == 416) //in case it is imp casted_spell_id = 23826; else if (unitTarget->getEntry() == 1860) //VoidWalker casted_spell_id = 23841; else if (unitTarget->getEntry() == 1863) //Succubus casted_spell_id = 23833; else if (unitTarget->getEntry() == 417) //Felhunter { casted_spell_id = 1; inc_resist_by_level_spell = 23837; inc_resist_by_level = 40; } else if (unitTarget->getEntry() == 17252) //Felguard { casted_spell_id = 35703; inc_resist_by_level_spell = 23837; inc_resist_by_level = 20; } if (casted_spell_id) { //for self Spell* sp = sSpellMgr.newSpell(p_caster, sSpellMgr.getSpellInfo(casted_spell_id), true, nullptr); SpellCastTargets tgt(p_caster->getGuid()); sp->prepare(&tgt); //for pet sp = sSpellMgr.newSpell(unitTarget, sSpellMgr.getSpellInfo(casted_spell_id), true, nullptr); SpellCastTargets tgt1(unitTarget->getGuid()); sp->prepare(&tgt1); } if (inc_resist_by_level_spell) { //for self Spell* sp = sSpellMgr.newSpell(p_caster, sSpellMgr.getSpellInfo(inc_resist_by_level_spell), true, nullptr); SpellCastTargets tgt(p_caster->getGuid()); sp->prepare(&tgt); //for pet sp = sSpellMgr.newSpell(unitTarget, sSpellMgr.getSpellInfo(inc_resist_by_level_spell), true, NULL); SpellCastTargets tgt1(unitTarget->getGuid()); sp->prepare(&tgt1); } return true; }
TEST_F(BalancingDeciderTest, new_policy_message) { std::vector<double> tgt(m_num_domain); m_balancer->update_policy(m_policy_message, *m_policy); m_policy->target(GEOPM_REGION_ID_EPOCH, tgt); // The first time it should split evenly for (int dom = 0; dom < m_num_domain; ++dom) { EXPECT_DOUBLE_EQ(13, tgt[dom]); } // Now skew the power balance m_policy->update(GEOPM_REGION_ID_EPOCH, 0, 12.0); m_policy->update(GEOPM_REGION_ID_EPOCH, 1, 14.0); // Double the power budget m_policy_message.power_budget = 208; m_balancer->update_policy(m_policy_message, *m_policy); m_policy->target(GEOPM_REGION_ID_EPOCH, tgt); // The first time it should split evenly for (int dom = 0; dom < m_num_domain; ++dom) { if (dom == 0) { EXPECT_DOUBLE_EQ(24, tgt[dom]); } else if (dom == 1) { EXPECT_DOUBLE_EQ(28, tgt[dom]); } else { EXPECT_DOUBLE_EQ(26, tgt[dom]); } } }
/** * Get the job url. * * @param name Production name * @param mc Should be true for MC * @param url On return, the job url * * @return true on success */ Bool_t GetJobUrl(const TString& name, Bool_t mc, TString& url) { url = ""; TString index("raw.jsp"); if (!Download((mc ? "job_details.jsp" : "production/raw.jsp"), index)) return false; std::ifstream in(index.Data()); TString line; TString tgt(Form("<td class=\"table_row\">%s</td>", name.Data())); do { line.ReadLine(in); if (!line.Contains(tgt)) continue; line.ReadLine(in); Int_t first = line.Index("href=\""); Int_t last = line.Index("\"", first+7); url = line(first+6,last-first-6); break; } while (!in.eof()); in.close(); if (url.IsNull()) { Error("GetJobUrl", "Production %s not found", name.Data()); return false; } return true; }
bool ProgSymbolWriter::writeSymbolsToFile(const Prog *prog, const QString &dstFileName) { LOG_VERBOSE("Writing symbols to '%1'", dstFileName); const QString fname = prog->getProject()->getSettings()->getOutputDirectory().absoluteFilePath( dstFileName); QSaveFile tgt(fname); if (!tgt.open(QFile::WriteOnly)) { LOG_ERROR("Cannot open '%1' for writing", fname); return false; } OStream f(&tgt); /* Print procs */ f << "/* Functions: */\n"; std::set<Function *> seen; for (UserProc *up : prog->getEntryProcs()) { printProcsRecursive(up, 0, f, seen); } f << "/* Leftovers: */\n"; for (const auto &m : prog->getModuleList()) { for (Function *pp : *m) { if (!pp->isLib() && (seen.find(pp) == seen.end())) { printProcsRecursive(pp, 0, f, seen); } } } f.flush(); return tgt.commit(); }
void SceneGraphNode::paint(QPainter* painter) { feather::status e; painter->setRenderHints(QPainter::Antialiasing, true); QPen trimPen = QPen(QColor(0,0,0),1); //trimPen.setStyle(Qt::NoPen); QPen textPen = QPen(QColor(NODE_TEXT_COLOR),2); QFont textFont("DejaVuSans",10); if(feather::smg::Instance()->selected(m_uid)) m_nodeFillBrush.setColor(QColor(SELECTED_NODE_COLOR)); else m_nodeFillBrush.setColor(QColor(DESELECTED_NODE_COLOR)); textFont.setBold((feather::smg::Instance()->selected(m_uid)) ? true : false); QBrush connInFillBrush = QBrush(QColor("#FF4500")); QBrush connOutFillBrush = QBrush(QColor("#DA70D6")); // set the node's height based on side with the most connections int max = 0; if(m_pInConns.size() > m_pOutConns.size()) max = m_pInConns.size(); else max = m_pOutConns.size(); //setWidth(NODE_WIDTH+4); //int height = (CONNECTION_HEIGHT * max) + NODE_HEIGHT; //setHeight(height+10); //setHeight(NODE_HEIGHT+44); // node trim painter->setPen(trimPen); // draw layer bar painter->setBrush(m_layerFillBrush); // draw title block painter->setBrush(m_nodeTitleBrush); painter->drawRect(CONNECTION_WIDTH+5,2,NODE_WIDTH-10,18); // draw the node block painter->setBrush(m_nodeFillBrush); painter->drawRect(CONNECTION_WIDTH,18,NODE_WIDTH,height()-20); // node icon QRectF tgt(CONNECTION_WIDTH + (NODE_WIDTH/2)-12,height()-24,24,24); QImage img(m_imgPath.str().c_str()); painter->drawImage(tgt,img); // node label painter->setPen(textPen); painter->setFont(textFont); std::string name; feather::qml::command::get_node_name(m_uid,name,e); painter->drawText(QRect(CONNECTION_WIDTH+5,2,NODE_WIDTH-10,18),Qt::AlignHCenter|Qt::AlignVCenter,name.c_str()); }
int s3fs_rename(const char *from, const char *to) { #ifdef DEBUG syslog(LOG_INFO, "rename[%s] -> [%s]", from, to); #endif try { Transaction t; // move the file over t.path = from; // if the file is a directory, rename_file will return the // Filecache object for the source so we can delete it at the end // we are responsible for releasing it, so hand it to our transaction t.file = rename_file(from, to, true); if (t.file) { // this is a directory, so rename all descendents Filecache::sync(); std::string marker; bool moretocome = true; while (moretocome) { stringlist entries; moretocome = S3request::get_directory(from, marker, entries, MAX_KEYS_PER_DIR_REQUEST, true); for (size_t i = 0; i < entries.size(); i++) { std::string src(from); src += "/" + entries[i]; std::string tgt(to); tgt += "/" + entries[i]; #ifdef DEBUG syslog(LOG_INFO, "rename[%s] -> [%s]", src.c_str(), tgt.c_str()); #endif // move the file over rename_file(src, tgt, false); } } // move any files inside the directory before removing the source t.file->deleted = true; Filecache::sync(); } return 0; } catch (int e) { syslog(LOG_INFO, "rename[%s] -> [%s]: %s", from, to, strerror(e)); return e; } }
void CloudRegister::pairAlign ( pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud_src, pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_tgt, Eigen::Matrix4f& final_transform, bool& hasICPConverged, bool downsample) { std::cout << "Number of cloud source : " << cloud_src->size() <<std::endl; std::cout << "Number of cloud target : " << cloud_tgt->size() <<std::endl; pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr src (new pcl::PointCloud<pcl::PointXYZRGBNormal>); pcl::PointCloud<pcl::PointXYZRGB>::Ptr tgt (new pcl::PointCloud<pcl::PointXYZRGB>); pcl::UniformSampling<pcl::PointXYZRGBNormal> sampling_with_normal; pcl::UniformSampling<pcl::PointXYZRGB> sampling; if (downsample) { sampling_with_normal.setRadiusSearch (0.05f); sampling_with_normal.setInputCloud (cloud_src); sampling_with_normal.filter(*src); sampling.setRadiusSearch (0.05f); sampling.setInputCloud (cloud_tgt); sampling.filter(*tgt); } else { src = cloud_src; tgt = cloud_tgt; } std::cout << "Number of sampled cloud source : " << src->size() << std::endl; std::cout << "Number of sampled cloud target : " << tgt->size() << std::endl; //concatenate point with its normal pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr points_with_normals_tgt = CloudNormalProvider::computePointWithNormal(tgt); pcl::IterativeClosestPoint<pcl::PointXYZRGBNormal, pcl::PointXYZRGBNormal> icp; icp.setTransformationEpsilon (1e-8); icp.setMaxCorrespondenceDistance (0.1); icp.setMaximumIterations (30); icp.setInputSource (src); icp.setInputTarget (points_with_normals_tgt); pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr result(new pcl::PointCloud<pcl::PointXYZRGBNormal>); icp.align(*result); if(icp.hasConverged()) { std::cout<< "score:" <<icp.getFitnessScore() << std::endl; final_transform = icp.getFinalTransformation().inverse(); hasICPConverged = true; } else { std::cout<< "gicp did not converged!" <<std::endl; } }
TEST_F(BalancingDeciderTest, update_policy) { std::vector<double> tgt(m_num_domain); m_policy_message.power_budget = 800; m_balancer->update_policy(m_policy_message, *m_policy); m_policy->target(GEOPM_REGION_ID_EPOCH, tgt); // The first time it should split evenly for (int dom = 0; dom < m_num_domain; ++dom) { EXPECT_DOUBLE_EQ(100.0, tgt[dom]); } m_balancer->update_policy(*m_region, *m_policy); m_policy->target(GEOPM_REGION_ID_EPOCH, tgt); double expect = 89.705882352941174; for (int dom = 0; dom < m_num_domain; ++dom) { EXPECT_NEAR(expect + (dom * 2.94117647058825), tgt[dom], 1E-9); } }
void FlannMatcher::evaluateTransform(Eigen::Matrix4f& transform, vector<Eigen::Vector3f>& eigenPoints1, vector<Eigen::Vector3f>& eigenPoints2, double maxError, vector<int>& inliers, double& meanError, float& ratio) { inliers.clear(); meanError=0.0; ratio=0.0; for(unsigned int i=0;i<eigenPoints1.size();i++) { Eigen::Vector4f src(eigenPoints1[ i ][ 0 ],eigenPoints1[ i ][ 1 ], eigenPoints1[ i ][ 2 ],1.); Eigen::Vector4f tgt(eigenPoints2[ i ][ 0 ],eigenPoints2[ i ][ 1 ], eigenPoints2[ i ][ 2 ],1.); Eigen::Vector4f diff=(transform*src)-tgt; double error=diff.dot(diff); if(error>maxError) continue; if(!(error>=0.0)) { //cerr<<"error is less than 0.0!!"<<endl; continue; } /* if(std::isnan(error)) continue; */ inliers.push_back(i); meanError+=sqrt(error); } //cout<<"inliers size is: "<<inliers.size()<<endl; if(inliers.size()>0) meanError/=inliers.size(); else meanError=-1.; ratio=(float)inliers.size()/eigenPoints1.size(); }
bool MakeJunction(const string& target, const string& junkpath, mgr_file::Attrs* attrs) { if (mgr_file::Exists(junkpath)) return false; if (!mgr_file::Exists(target)) return false; mgr_file::Info nfo(target); if (!nfo.IsDir()) return false; mgr_file::MkDir(junkpath, attrs); str::u16string tgt(target); str::u16string junk(junkpath); ResHandle hLink(OpenLinkHandle(str::u16string(junkpath).c_str(), GENERIC_WRITE)); if ((bool)hLink) { str::u16string SubstituteName("\\??\\" + target); REPARSE_BUF rdb; rdb->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; rdb.fill(tgt.c_str(), tgt.size(), SubstituteName.c_str(), SubstituteName.size()); if (rdb.set(junk.c_str())) { return true; } } mgr_file::Remove(junkpath); return false; }
// struct jsdl_data_staging // { // struct jsdl_data_staging * next; // char * name; // char * FileName; // char * FileSystemName; // enum jsdl_creation_flags CreationFlag; // int DeleteOnTermination; // char * Source; // char * Target; // struct hpcp_credential * Credential; // }; void job_description::set_file_transfers (std::vector <std::string> specs) { // " http://host.one/data/one >> ftp://host.two/stage/two" // "UserPass @ http://host.one/data/one > ftp://host.two/stage/two" std::string spec_pattern = "^(([^ ]+) +@ +)?([^ ><]+) *(>|>>|<|<<) *([^ ><]+)$"; regex_t regex; if ( 0 != regcomp (®ex, spec_pattern.c_str (), REG_EXTENDED) ) { throw "regcomp() failed"; // FIXME errno } for ( unsigned int i = 0; i < specs.size (); i++ ) { std::string spec = specs[i]; size_t nmatch = 6; regmatch_t pmatch[6]; std::cout << "parsing '" << spec << "' against '" << spec_pattern << "'" << std::endl; if ( 0 != regexec (®ex, spec.c_str (), nmatch, pmatch, 0) ) { throw "regexec() failed"; // FIXME errno } std::vector <std::string> matches; matches.resize (6, ""); for ( unsigned int j = 0; j < nmatch; j++ ) { if ( pmatch[j].rm_so != -1 ) { for ( int k = pmatch[j].rm_so; k < pmatch[j].rm_eo; k++ ) { matches[j] += spec[k]; } } std::cout << " spec match " << j << " : " << matches[j] << std::endl; } std::string fname (""); std::string fsys (""); std::string src (""); std::string tgt (""); std::string ctx (""); staging_flag flag; bool cleanup = false; std::cout << "matches: " << matches.size () << std::endl; // 0 1 2 3 4 5 // "^( ([^\\s]+)\\s+@\\s+)?([^\\><s]+)\\s*(>|>>|<|<<)\\s*([^\\><s]+)$"; ctx = matches[2]; if ( matches[4] == ">" || matches[4] == ">>" ) { // stage in src = matches[3]; fname = matches[5]; if ( matches[4] == ">" ) { flag = Overwrite; } else { flag = Append; } } else if ( matches[4] == "<" || matches[4] == "<<" ) { // stage out tgt = matches[3]; fname = matches[5]; if ( matches[4] == "<" ) { flag = Overwrite; } else { flag = Append; } } else { throw "invalid file transfer operation"; // FIXME: details } struct jsdl_data_staging * file = new struct jsdl_data_staging; file->next = NULL; file->name = NULL; file->FileName = NULL; file->FileSystemName = NULL; file->CreationFlag = jsdl_nocreationflag; file->DeleteOnTermination = 0; file->Source = NULL; file->Target = NULL; file->Credential = NULL; if ( ! fname.empty () ) { file->FileName = ::strdup (fname.c_str ()); if ( file->FileName == NULL ) { throw "strdup error"; } } if ( ! fsys.empty () ) { file->FileSystemName = ::strdup (fsys.c_str ()); if ( file->FileSystemName == NULL ) { throw "strdup error"; } } if ( flag & Overwrite ) { file->CreationFlag = jsdl_overwrite; } else if ( flag & Append ) { file->CreationFlag = jsdl_append; } else if ( flag & DontOverwrite ) { file->CreationFlag = jsdl_dontOverwrite; } if ( cleanup ) { file->DeleteOnTermination = 1; } if ( ! src.empty () ) { file->Source = ::strdup (src.c_str ()); if ( file->Source == NULL ) { throw "strdup error"; } } if ( ! tgt.empty () ) { file->Target = ::strdup (tgt.c_str ()); if ( file->Target == NULL ) { throw "strdup error"; } } if ( ! ctx.empty () ) { std::cout << "no credential support for file staging, yet: " << ctx << std::endl; // throw "no credential support for file staging, yet"; // struct hpcp_credential * cred = NULL; // if ( (rc = jsdl_processCredential(cur, &cred)) != BESE_OK ) // { // jsdl_freeDataStaging(file); // return rc; // } // file->Credential = cred; } struct jsdl_data_staging * cur_file = jsdl_->DataStaging; if ( cur_file ) { while ( cur_file->next ) { cur_file = cur_file->next; } cur_file->next = file; } else { jsdl_->DataStaging = file; } } regfree (®ex); // FIXME: we should re-use the compiled regex }
int main( int argc, char** argv ) { ros::init(argc, argv, "KITTI"); int offset = 0; int maxId = 4000; KITTI kitti(0,maxId,offset); loam_wrapper loam; std::vector<Eigen::Matrix4d> T_result; std::vector<Eigen::Matrix4d> T_result_delta; T_result.push_back(Eigen::Matrix4d::Identity()); Eigen::Matrix4d T_offset = kitti.getGroundTruthByID(offset); Eigen::Matrix4d T_all_od = kitti.getGroundTruthByID(offset); Eigen::Matrix4d T_all_map = kitti.getGroundTruthByID(offset); Eigen::Matrix4d T_diff_od_map; Eigen::Matrix4d T_Velo_to_Cam = kitti.getVelo_to_cam_T(); for (int i=offset; i<maxId-1;i++) { pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_source_filtered (new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_target_filtered (new pcl::PointCloud<pcl::PointXYZ>); // Get Input Clouds pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_source(new pcl::PointCloud<pcl::PointXYZ>()); kitti.getOneVel(cloud_source_filtered,i); pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_target(new pcl::PointCloud<pcl::PointXYZ>()); kitti.getOneVel(cloud_target_filtered,i+1); pcl::VoxelGrid<pcl::PointXYZ> downSizeFilter; downSizeFilter.setInputCloud(cloud_source_filtered); downSizeFilter.setLeafSize(0.1f, 0.1f, 0.1f); downSizeFilter.filter(*cloud_source); pcl::VoxelGrid<pcl::PointXYZ> downSizeFilter2; downSizeFilter2.setInputCloud(cloud_target_filtered); downSizeFilter2.setLeafSize(0.1f, 0.1f, 0.1f); downSizeFilter2.filter(*cloud_target); // Transform into Cam coordinate system pcl::transformPointCloud(*cloud_source, *cloud_source, T_Velo_to_Cam); pcl::transformPointCloud(*cloud_target, *cloud_target, T_Velo_to_Cam); // transform according to ground truth Eigen::Matrix4d T_1 = kitti.getGroundTruthByID(i); Eigen::Matrix4d T_2 = kitti.getGroundTruthByID(i+1); Eigen::Matrix4d T_diff = T_1.inverse() * T_2; pcl::transformPointCloud (*cloud_target, *cloud_target, T_diff); loam.publishFirst(cloud_source); loam.publishSecond(cloud_target); pcl::PointCloud<pcl::PointNormal>::Ptr src(new pcl::PointCloud<pcl::PointNormal>); pcl::copyPointCloud(*cloud_source, *src); pcl::PointCloud<pcl::PointNormal>::Ptr tgt(new pcl::PointCloud<pcl::PointNormal>); pcl::copyPointCloud(*cloud_target, *tgt); pcl::NormalEstimation<pcl::PointNormal, pcl::PointNormal> norm_est; norm_est.setSearchMethod (pcl::search::KdTree<pcl::PointNormal>::Ptr (new pcl::search::KdTree<pcl::PointNormal>)); norm_est.setKSearch (10); norm_est.setInputCloud (tgt); norm_est.compute (*tgt); pcl::IterativeClosestPoint<pcl::PointNormal, pcl::PointNormal> icp; typedef pcl::registration::TransformationEstimationPointToPlane<pcl::PointNormal, pcl::PointNormal> PointToPlane; boost::shared_ptr<PointToPlane> point_to_plane(new PointToPlane); icp.setTransformationEstimation(point_to_plane); icp.setInputCloud(src); icp.setInputTarget(tgt); icp.setRANSACOutlierRejectionThreshold(0.05); icp.setRANSACIterations(100); icp.setMaximumIterations(1000); icp.setTransformationEpsilon(1e-3); pcl::PointCloud<pcl::PointNormal> output; icp.align(output); // Obtain the transformation that aligned cloud_source to cloud_source_registered Eigen::Matrix4d T_back= icp.getFinalTransformation().cast<double>(); T_all_map = T_back * T_all_map * T_diff; Eigen::Matrix4d T_gt = kitti.getGroundTruthDeltaByID(i); T_result_delta.push_back(T_back); T_all_od = T_offset*loam.T_total_od; std::cout << "[INFO]: i=" << i << std::endl; std::cout << "T_back:" << T_back << std::endl; std::cout << "T_all_od:" << T_all_od << std::endl; std::cout << "T_all_map:" << T_all_map << std::endl; std::cout << "T_gt:" << kitti.getGroundTruthByID(i) << std::endl; std::cout << "T_diff_od_map:" << T_diff_od_map << std::endl; T_result.push_back(T_all_map); loam.publishFirst(cloud_source); pcl::transformPointCloud (*cloud_target, *cloud_target, T_back); loam.publishSecond(cloud_target); } kitti.plotDeltaPoses(T_result,0); kitti.eval(T_result); return 0; }
void InverseDistanceInterpolation<KDDim>::interpolate_field_data (const std::vector<std::string> &field_names, const std::vector<Point> &tgt_pts, std::vector<Number> &tgt_vals) const { libmesh_experimental(); // forcibly initialize, if needed #ifdef LIBMESH_HAVE_NANOFLANN if (_kd_tree.get() == NULL) const_cast<InverseDistanceInterpolation<KDDim>*>(this)->construct_kd_tree(); #endif START_LOG ("interpolate_field_data()", "InverseDistanceInterpolation<>"); libmesh_assert_equal_to (field_names.size(), this->n_field_variables()); // If we already have field variables, we assume we are appending. // that means the names and ordering better be identical! if (_names.size() != field_names.size()) { libMesh::err << "ERROR: when adding field data to an existing list the\n" << "varaible list must be the same!\n"; libmesh_error(); } for (unsigned int v=0; v<_names.size(); v++) if (_names[v] != field_names[v]) { libMesh::err << "ERROR: when adding field data to an existing list the\n" << "varaible list must be the same!\n"; libmesh_error(); } tgt_vals.resize (tgt_pts.size()*this->n_field_variables()); #ifdef LIBMESH_HAVE_NANOFLANN { std::vector<Number>::iterator out_it = tgt_vals.begin(); const size_t num_results = std::min((size_t) _n_interp_pts, _src_pts.size()); std::vector<size_t> ret_index(num_results); std::vector<Real> ret_dist_sqr(num_results); for (std::vector<Point>::const_iterator tgt_it=tgt_pts.begin(); tgt_it != tgt_pts.end(); ++tgt_it) { const Point &tgt(*tgt_it); const Real query_pt[] = { tgt(0), tgt(1), tgt(2) }; _kd_tree->knnSearch(&query_pt[0], num_results, &ret_index[0], &ret_dist_sqr[0]); this->interpolate (tgt, ret_index, ret_dist_sqr, out_it); // libMesh::out << "knnSearch(): num_results=" << num_results << "\n"; // for (size_t i=0;i<num_results;i++) // libMesh::out << "idx[" << i << "]=" // << std::setw(6) << ret_index[i] // << "\t dist["<< i << "]=" << ret_dist_sqr[i] // << "\t val[" << std::setw(6) << ret_index[i] << "]=" << _src_vals[ret_index[i]] // << std::endl; // libMesh::out << "\n"; // libMesh::out << "ival=" << _vals[0] << '\n'; } } #else libMesh::err << "ERROR: This functionality requires the library to be configured\n" << "with nanoflann KD-Tree approximate nearest neighbor support!\n" << std::endl; libmesh_error(); #endif STOP_LOG ("interpolate_field_data()", "InverseDistanceInterpolation<>"); }
// --------------------------------------------------------------------------- // // ----------- void bXMapTopoCheck::process_objects(bArray& objects){ //_bTrace_("bXMapTopoCheck::process_objects",true); int i,j,k,l,m; bGenericGeoElement *a,*b,*t; ivertices *vsa,*vsb,*vst; ivx_rect vr; bGenericType* tp; bArray tgt(sizeof(bGenericGeoElement*)); get_prm prm; bArray modifs(sizeof(mod_prm)); mod_prm mod; prm.arr=&tgt; for(i=1;i<=objects.count();i++){ objects.get(i,&a); b=a->get_ref(); a->getVertices(&vsa); b->getVertices(&vsb); tgt.reset(); for(j=1;j<=_types.count();j++){ _types.get(j,&tp); if(!tp){ continue; } a->getBounds(&vr); tgt.reset(); tp->iterator()->iterate(&vr,&prm,get_objects); //_tm_("count="+tgt.count()); for(k=1;k<=tgt.count();k++){ tgt.get(k,&t); t->getVertices(&vst); mod.vxs=NULL; for(l=0;l<vsa->nv;l++){ for(m=0;m<vst->nv;m++){ if(eq_ivx2(&vsa->vx.vx2[l],&vst->vx.vx2[m])){ if(mod.vxs==NULL){ ivs2ivs(vst,&mod.vxs); } mod.vxs->vx.vx2[m]=vsb->vx.vx2[l]; } } } if(mod.vxs!=NULL){ mod.o=t; modifs.add(&mod); } } } } if(modifs.count()>0){ for(i=1;i<=objects.count();i++){ objects.get(i,&a); b=a->get_ref(); a->getVertices(&vsa); b->getVertices(&vsb); mod.o=b; ivs2ivs(vsb,&mod.vxs); modifs.add(&mod); b->setVertices(vsa); } bEventLog log(_gapp,this); for(i=1;i<=modifs.count();i++){ modifs.get(i,&mod); mod.o->setVertices(mod.vxs); ivs_free(mod.vxs); } log.close(); } }
void GameObject::Update(uint32 p_time) { if(m_event_Instanceid != m_instanceId) { event_Relocate(); return; } if(!IsInWorld()) return; if(m_deleted) return; if(spell && (GetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE) == 1)) { if(checkrate > 1) { if(counter++%checkrate) return; } Object::InRangeSet::iterator itr,it2; Unit* pUnit; float dist; for( it2 = GetInRangeSetBegin(); it2 != GetInRangeSetEnd(); ++it2) { itr = it2; dist = GetDistanceSq((*itr)); if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range) { pUnit = TO_UNIT(*itr); if(m_summonedGo) { if(!m_summoner) { ExpireAndDelete(); return; } if(!isAttackable(m_summoner,pUnit))continue; } Spell* sp= (new Spell(TO_OBJECT(this),spell,true,NULL)); SpellCastTargets tgt((*itr)->GetGUID()); tgt.m_destX = GetPositionX(); tgt.m_destY = GetPositionY(); tgt.m_destZ = GetPositionZ(); sp->prepare(&tgt); if(pInfo->Type == 6) { if(m_summoner != NULL) m_summoner->HandleProc(PROC_ON_TRAP_TRIGGER, pUnit, spell); } if(m_summonedGo) { ExpireAndDelete(); return; } if(spell->EffectImplicitTargetA[0] == 16 || spell->EffectImplicitTargetB[0] == 16) return; // on area dont continue. } } } }
void GameObject::Update(uint32 p_time) { if(m_event_Instanceid != m_instanceId) { event_Relocate(); return; } if(!IsInWorld()) return; if(m_deleted) return; if(spell && (GetUInt32Value(GAMEOBJECT_STATE) == 1)) { if(checkrate > 1) { if(counter++%checkrate) return; } ObjectSet::iterator itr = GetInRangeSetBegin(); ObjectSet::iterator it2 = itr; ObjectSet::iterator iend = GetInRangeSetEnd(); Unit * pUnit; float dist; for(; it2 != iend;) { itr = it2; ++it2; dist = GetDistanceSq((*itr)); if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range) { pUnit = static_cast<Unit*>(*itr); if(m_summonedGo) { if(!m_summoner) { ExpireAndDelete(); return; } if(!isAttackable(m_summoner,pUnit))continue; } Spell * sp=new Spell((Object*)this,spell,true,NULL); SpellCastTargets tgt((*itr)->GetGUID()); tgt.m_destX = GetPositionX(); tgt.m_destY = GetPositionY(); tgt.m_destZ = GetPositionZ(); sp->prepare(&tgt); if(m_summonedGo) { ExpireAndDelete(); return; } if(spell->EffectImplicitTargetA[0] == 16 || spell->EffectImplicitTargetB[0] == 16) return; // on area dont continue. } } } }
Action EccChaserCalculatingActuator::actuate(IoPage &outp, bool interactive) { fuel_ = outp[fuelOutPort]; Action act = Action(); Vector tgt(outp[tsxOutPort], outp[tsyOutPort]); Vector g; if (me_.r_ > 0) { g = PhysUtil::scaleVectorToLength(me_.pos_, PhysUtil::calcFreefallAcceleration(me_.r_)); } Scalar dist = PhysUtil::calcModulus(tgt); me_.pushPos(Vector(outp[msxOutPort], outp[msyOutPort])); him_.pushPos(PhysUtil::subtractVectors(me_.pos_, tgt)); bool newLine = (delay_ > 0); if (me_.lastR_ < 1) { // little is known about the world if (interactive) { std:: cout << std::endl << "Just starting..." << std::endl; newLine = true; } //waypoint_ = 200000.0; waypoint_ = 0.0; me_.targetR_ = him_.r_; makeFreefallAction(act); } /* else if (((delay_ == 0) || (waypoint_ != 0)) && wait_) { std::cout<<"D0: "<<(dist / 1000)<<" sgn: "<<PhysUtil::calcCodirectionality(me_.mov_,tgt)<<std::endl; //Word aa;std::cin>>aa; //if (dist < (std::abs(me_.r_ - him_.r_) * 1.5)) { if ((dist < (std::abs(waypoint_) * 4)) || (dist > (std::abs(waypoint_) * 25)) || ((PhysUtil::calcCodirectionality(me_.mov_, tgt) / waypoint_) < 0)) { if (interactive) { std::cout << std::endl << std::endl << "*** WAYPOINT ***" << std::endl << std::endl; //Word aa;std::cin>>aa; } //waypoint_ = ((waypoint_ < dist) ? 100000 : (waypoint_ / 2)); //waypoint_ -= 25000.0; //waypoint_ /= 4.0; waypoint_ = (dist / 8) * PhysUtil::calcCodirectionality(me_.mov_, tgt); if (interactive) { std::cout << std::endl << "dist: " << dist << " cod: " << PhysUtil::calcCodirectionality(me_.mov_, tgt); std::cout << std::endl << "selected new waypoint: " << waypoint_ << std::endl; } wait_ = false; if (dist < 50000) { secondThrust_ = true; } } if (delay_ == 0) { Vector vd = PhysUtil::addVectors(PhysUtil::scaleAndRotateVector(me_.pos_, PhysUtil::calcCircOrbitalSpeed(me_.r_), me_.mov_), PhysUtil::multVector(g, 0.5)); Vector vn = PhysUtil::addVectors(me_.mov_, g); Vector cThrust = PhysUtil::subtractVectors(vd, vn); //std::cout << std::endl << "ct:" << PhysUtil::calcModulus(cThrust) << std::endl; //Word aa;std::cin >> aa; if (PhysUtil::calcModulus(cThrust) > 0.1) { delay_ = 3; makeThrusterCorrectionAction(act, cThrust); } else { makeFreefallAction(act); } } else { makeFreefallAction(act); } } else if (((delay_ == 0) || (waypoint_ != 0)) && !firstThrust_) { firstThrust_ = true; me_.targetR_ = him_.r_ - waypoint_; calcThrusts(me_.r_, me_.targetR_); Vector vThrust = PhysUtil::scaleVectorToLength(me_.mov_, firstThrustDv_); makeThrusterAction(act, vThrust); } else if (!secondThrust_) { if ((std::abs(me_.h_) < orbitalTolerance) && (std::abs(me_.lastH_) < std::abs(me_.h_))) { if (interactive) { std::cout << std::endl << std::endl << "Second thrust!" << std::endl << std::endl; newLine = true; } Vector vThrust = PhysUtil::scaleVectorToLength(me_.mov_, secondThrustDv_); makeThrusterAction(act, vThrust); //if (waypoint_ > 0) { firstThrust_ = false; waypoint_ = 0.1; wait_ = true; delay_ = 10; //} //else { // secondThrust_ = true; // delay_ = 10; //} } else { makeFreefallAction(act); } } else { makeFreefallAction(act); } */ //if ((delay_ == 0) && secondThrust_) { // chase! else if (delay_ == 0) { if (reserveFuel_ == 0) { reserveFuel_ = fuel_ - 15000; } Vector g = PhysUtil::scaleVectorToLength(me_.pos_, PhysUtil::calcFreefallAcceleration(me_.r_)); if (fuel_ > reserveFuel_) { Scalar toTgtSc = ((dist > 3) ? (dist * 0.1) : 0); Vector toTgt = PhysUtil::scaleVectorToLength(tgt, ((toTgtSc > 2500) ? 2500 : toTgtSc)); Vector fixSpd = PhysUtil::subtractVectors(him_.mov_, me_.mov_); //Vector cThrust = PhysUtil::subtractVectors(PhysUtil::addVectors(toTgt, fixSpd), g); //Vector cThrust = PhysUtil::subtractVectors(PhysUtil::addVectors(toTgt, fixSpd), PhysUtil::multVector(g, 0.5)); Vector cThrust = PhysUtil::addVectors(toTgt, fixSpd); if ((dist < 3) && PhysUtil::calcModulus(PhysUtil::subtractVectors(him_.mov_, me_.mov_)) < 0.5) { //(PhysUtil::calcModulus(cThrust) < 1) reserveFuel_ = 1000000; } makeThrusterCorrectionAction(act, cThrust); if (interactive) { std::cout << std::endl; } delay_ = 10; } /* if (dist > 100) { Vector toTgt = PhysUtil::scaleVectorToLength(PhysUtil::addVectors(tgt, PhysUtil::addVectors(him_.mov_, him_.mov_)), dist * 0.5); Vector cThrust = PhysUtil::subtractVectors(PhysUtil::subtractVectors(toTgt, PhysUtil::addVectors(me_.mov_, me_.mov_)), g); makeThrusterCorrectionAction(act, cThrust); delay_ = 2; } else { Vector dv = PhysUtil::subtractVectors(him_.mov_, me_.mov_); if (PhysUtil::calcModulus(dv) > 0.5) { makeThrusterCorrectionAction(act, dv); } else { makeFreefallAction(act); } } */ } else { makeFreefallAction(act); } Word iDist = dist; Word kmDist = iDist / 1000; Word mDist = iDist % 1000; if (kmDist) { cnt_ = 0; } else { ++cnt_; } if (interactive) { std::cout.precision(0); std::cout << std::fixed << " v: " << PhysUtil::calcModulus(him_.mov_) << " dist: " << (kmDist ? kmDist : mDist) << (kmDist ? " km " : " m ") << " dx: " << outp[4] << " dy: " << outp[5] << " f: " << fuel_ << " mR: " << me_.r_ << " tR: " << him_.r_ << " div: " << PhysUtil::calcModulus(PhysUtil::subtractVectors(him_.mov_, me_.mov_)) << " cnt: " << cnt_ << " g: " << PhysUtil::calcModulus(g) << " " << "\r"; //(delay_ ? "\n" : "\r"); //std::cout<<std::endl;Word aa;std::cin>>aa; } if (delay_ > 0) { --delay_; } return act; }
void file_cpi_impl::sync_copy (saga::impl::void_t & ret, saga::url dest, int flags) { adaptor_data_t adata (this); file_instance_data_t idata (this); // check preconditions // We can only check coditions for local targets if ( saga::adaptors::utils::is_local_address (dest) ) { saga::filesystem::directory loc ("/"); if ( loc.exists (dest.get_path ()) ) { if ( ! (flags & saga::name_space::Overwrite) ) { std::stringstream ss; ss << "Target exists: " << dest; SAGA_ADAPTOR_THROW (ss.str (), saga::AlreadyExists); } } } std::string src (u_.get_string ()); std::string tgt (dest.get_string ()); CURLcode code; // get handle for input and output curl ops (see README) CURL * in = adata->get_curl_handle_in (); CURL * out = adata->get_curl_handle_out (); // create buffer file FILE * buf = ::fopen ("/tmp/curl-cache.dat", "w+"); ensure (NULL != buf, "fopen() failed: ", ::strerror (errno)); // read data into buffer code = curl_easy_setopt (in, CURLOPT_URL, src.c_str ()); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_setopt (in, CURLOPT_WRITEDATA, buf); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_perform (in); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); // data are in buffer - now rewind buffer, and copy data to target location ::rewind (buf); code = curl_easy_setopt (out, CURLOPT_URL, tgt.c_str ()); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_setopt (out, CURLOPT_VERBOSE, "true"); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_setopt (out, CURLOPT_USERPWD, "merzky:Z(I)nfandel"); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_setopt (out, CURLOPT_UPLOAD, "true"); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_setopt (out, CURLOPT_READDATA, buf); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); code = curl_easy_perform (out); ensure (0 == code, "Curl Error: ", curl_easy_strerror (code)); ::fclose (buf); // done :-) }
void MiniDebugger::miniDebugger(UserProc *proc, const char *description) { OStream q_cout(stdout); QTextStream q_cin(stdin); q_cout << "decompiling " << proc->getName() << ": " << description << "\n"; QString stopAt; if (stopAt.isEmpty() || !proc->getName().compare(stopAt)) { // This is a mini command line debugger. Feel free to expand it. for (const Statement *stmt : watches) { stmt->print(q_cout); q_cout << "\n"; } q_cout << " <press enter to continue> \n"; QString line; while (true) { line.clear(); q_cin >> line; if (line.startsWith("print")) { proc->print(q_cout); } else if (line.startsWith("fprint")) { QFile tgt("out.proc"); if (tgt.open(QFile::WriteOnly)) { OStream of(&tgt); proc->print(of); } } else if (line.startsWith("run ")) { QStringList parts = line.trimmed().split(" ", QString::SkipEmptyParts); if (parts.size() > 1) { stopAt = parts[1]; } break; } else if (line.startsWith("watch ")) { QStringList parts = line.trimmed().split(" ", QString::SkipEmptyParts); if (parts.size() > 1) { int n = parts[1].toInt(); StatementList stmts; proc->getStatements(stmts); StatementList::iterator it; for (it = stmts.begin(); it != stmts.end(); ++it) { if ((*it)->getNumber() == n) { watches.insert(*it); q_cout << "watching " << *it << "\n"; } } } } else { break; } } } }
// -------------------------------------------------------------------------- // quand on est aligne avec un pont et situe a son entree, on part de l'autre // cote du pont. Si les bumpers de pont disent qu'il y a un trou, on recule. // -------------------------------------------------------------------------- bool StrategyAttackCL::crossBridge() { Point tgt(BRIDGE_CROSS_BRIDGE_X, RobotPos->y()); if (bridgeDetectionByCenter_) { if (bridge_ == BRIDGE_POS_CENTER || bridge_ == BRIDGE_POS_MIDDLE_CENTER) { tgt.y=BRIDGE_ENTRY_SIOUX_Y; } else if (bridge_ == BRIDGE_POS_MIDDLE_BORDURE) { tgt.y=BRIDGE_ENTRY_MIDDLE_BORDURE_Y; } else if (bridge_ == BRIDGE_POS_BORDURE) { tgt.y=BRIDGE_ENTRY_BORDURE_Y; } } else { if (bridge_ == BRIDGE_POS_CENTER) { tgt.y=BRIDGE_ENTRY_CENTER_Y; } else if (bridge_ == BRIDGE_POS_MIDDLE_CENTER) { tgt.y=BRIDGE_ENTRY_MIDDLE_CENTER_Y; } else if (bridge_ == BRIDGE_POS_MIDDLE_BORDURE) { tgt.y=BRIDGE_ENTRY_MIDDLE_BORDURE_Y; } else if (bridge_ == BRIDGE_POS_BORDURE) { tgt.y=BRIDGE_ENTRY_BORDURE_Y; } } if (!useLeftBridge_) { tgt.y = TERRAIN_Y - tgt.y; } // verifie qu'on est bien aligne if (fabs(tgt.y-RobotPos->y()) > BRIDGE_ENTRY_MARGIN) return false; int retry=0; LOG_COMMAND("crossBridge: %s\n", tgt.txt()); Move->enableAccelerationController(true); do { MvtMgr->setRobotDirection(MOVE_DIRECTION_FORWARD); Move->go2Target(tgt); enableBridgeCaptors(); bool dummyBumperEvt=true; while(dummyBumperEvt) { Events->wait(evtEndMoveBridge); Move->enableAccelerationController(false); if (checkBridgeBumperEvent(dummyBumperEvt)) { if (RobotPos->x()> 1600) { useBridgeBumpers_=false; disableBridgeCaptors(); dummyBumperEvt = true; continue; } else { Move->backward(100); Events->wait(evtEndMoveNoCollision); return false; } } else if (dummyBumperEvt) { Move->enableAccelerationController(true); Move->go2Target(tgt); enableBridgeCaptors(); } } if (RobotPos->x()> 1600) { useBridgeBumpers_=false; disableBridgeCaptors(); } // on a reussi a traverser? if (Events->isInWaitResult(EVENTS_MOVE_END)) return true; // c'est la fin du match? if (checkEndEvents()) return false; // on s'est plante, on recule un peu, on se reoriente et on // repart! Move->realign(0); Events->wait(evtEndMoveNoCollision); if (checkEndEvents()) return false; Move->backward(100); // Events->wait(evtEndMoveNoCollision); // if (checkEndEvents()) return false; // Move->rotate(0); Events->wait(evtEndMoveNoCollision); if (checkEndEvents()) return false; } while (retry++<5); // on n'a pas reussi a traverser par ici... on recule et on essaye ailleurs MvtMgr->setRobotDirection(MOVE_DIRECTION_BACKWARD); tgt.x=BRIDGE_DETECT_SHARP_X; Move->go2Target(tgt); Events->wait(evtEndMoveNoCollision); return false; }
int __cdecl main(int argc, char* argv[]) { if(argc < 3) { return 0; } try { string tmp; File src(argv[1], File::READ, File::OPEN, false); File tgt(argv[2], File::WRITE, File::CREATE | File::TRUNCATE, false); File example(argv[3], File::WRITE, File::CREATE | File::TRUNCATE, false); string x = src.read(); x = Text::acpToUtf8(x); string::size_type k; while((k = x.find('\r')) != string::npos) { x.erase(k, 1); } StringList l = StringTokenizer<string>(x, '\n').getTokens(); StringIter i; string varStr; string varName; string start; SimpleXML ex; for(i = l.begin(); i != l.end(); ) { if( (k = i->find("// @Strings: ")) != string::npos) { varStr = i->substr(k + 13); i = l.erase(i); } else if( (k = i->find("// @Names: ")) != string::npos) { varName = i->substr(k + 11); i = l.erase(i); } else if(i->find("// @DontAdd") != string::npos) { i = l.erase(i); } else if( (k = i->find("// @Prolog: ")) != string::npos) { start += i->substr(k + 12) + "\r\n"; i = l.erase(i); } else if(i->size() < 5) { i = l.erase(i); } else { ++i; } } if(varStr.empty() || varName.empty()) { printf("No @Strings or @Names\n"); return 0; } varStr += " = {\r\n"; varName += " = {\r\n"; /* ex.addTag("Language"); ex.addChildAttrib("Name", string("Example Language")); ex.addChildAttrib("Author", string("FlylinkDC++ Development Team")); //ex.addChildAttrib("Version", string(A_VERSIONSTRING)); ex.addChildAttrib("Revision", string("1")); ex.stepIn(); */ ex.addTag("resources"); ex.stepIn(); string name; string def; string xmldef; string s; for(i = l.begin(); i != l.end(); i++) { name.clear(); s = *i; bool u = true; for(k = s.find_first_not_of(" \t"); s[k] != ','; k++) { if(s[k] == '_') { u = true; } else if(u) { name+=s[k]; u = false; } else { name+=(char)tolower(s[k]); } } k = s.find("// "); def = s.substr(k + 3); xmldef = def.substr(1, def.size() - 2); /* while( (k = xmldef.find("\\t")) != string::npos) { xmldef.replace(k, 2, "\t"); } while( (k = xmldef.find("\\r")) != string::npos) { xmldef.replace(k, 2, "\r"); } while( (k = xmldef.find("\\n")) != string::npos) { xmldef.replace(k, 2, "\n"); } while( (k = xmldef.find("\\\\")) != string::npos) { xmldef.replace(k, 2, "\\"); } */ ex.addTag("string", xmldef); ex.addChildAttrib("name", name); varStr += def + ", \r\n"; varName += '\"' + name + "\", \r\n"; } varStr.erase(varStr.size()-2, 2); varName.erase(varName.size()-2, 2); varStr += "\r\n};\r\n"; varName += "\r\n};\r\n"; tgt.write(start); tgt.write(varStr); tgt.write(varName); example.write(SimpleXML::utf8Header); example.write(ex.toXML()); } catch(const Exception& e) { printf("%s\n", e.getError().c_str()); } return 0; }
void GameObject::Update(uint32 p_time) { if(m_event_Instanceid != m_instanceId) { event_Relocate(); return; } if(!IsInWorld()) return; if(m_deleted) return; if(spell && (GetUInt32Value(GAMEOBJECT_STATE) == 1)) { if(checkrate > 1) { if(counter++%checkrate) return; } ObjectSet::iterator itr = GetInRangeSetBegin(); ObjectSet::iterator it2 = itr; ObjectSet::iterator iend = GetInRangeSetEnd(); Unit * pUnit; float dist; this->AquireInrangeLock(); //make sure to release lock before exit function ! for(; it2 != iend;) { itr = it2; ++it2; dist = GetDistanceSq((*itr)); if( (*itr) != m_summoner && (*itr)->IsUnit() && dist <= range) { pUnit = static_cast<Unit*>(*itr); if(m_summonedGo) { if(!m_summoner) { ExpireAndDelete(); return; } if(!isAttackable(m_summoner,pUnit))continue; } Spell * sp=SpellPool.PooledNew(); sp->Init((Object*)this,spell,true,NULL); SpellCastTargets tgt((*itr)->GetGUID()); tgt.m_destX = GetPositionX(); tgt.m_destY = GetPositionY(); tgt.m_destZ = GetPositionZ(); sp->prepare(&tgt); // proc on trap trigger if( pInfo->Type == GAMEOBJECT_TYPE_TRAP ) { if( m_summoner != NULL ) m_summoner->HandleProc( PROC_ON_TRAP_TRIGGER, pUnit, spell ); } if(m_summonedGo) { ExpireAndDelete(); this->ReleaseInrangeLock(); return; } if(spell->EffectImplicitTargetA[0] == 16 || spell->EffectImplicitTargetB[0] == 16) { this->ReleaseInrangeLock(); return; // on area dont continue. } } } this->ReleaseInrangeLock(); } }