void propagate_argument_rec( Node* current, RenameVisitor* v ) { if( !current->is_visited( ) ) { current->set_visited( true ); if( current->is_entry_node( ) || current->is_exit_node( ) ) return; if( current->is_graph_node( ) ) { propagate_argument_rec( current->get_graph_entry_node( ), v ); } else { ObjectList<Nodecl::NodeclBase> stmts = current->get_statements( ); ObjectList<Nodecl::NodeclBase> new_stmts; for( ObjectList<Nodecl::NodeclBase>::iterator it = stmts.begin( ); it != stmts.end( ); ++it ) { Nodecl::NodeclBase it_copy = Nodecl::Utils::deep_copy( *it, *it ); v->walk( *it ); new_stmts.insert( it_copy ); } current->set_statements( new_stmts ); } ObjectList<Node*> children = current->get_children( ); for( ObjectList<Node*>::iterator it = children.begin( ); it != children.end( ); ++it ) { propagate_argument_rec( *it, v ); } } }
void Player::mergeObjectList(ObjectList &orig, const ObjectList &newobjs, SelectionFlags_t flags) { if(flags == SelectionFlags::SET) { orig = newobjs; } else if(flags == SelectionFlags::ADD) { for(ObjectList::const_iterator it = newobjs.begin(); it != newobjs.end(); ++it) { ObjectList::const_iterator it2 = std::find(orig.begin(), orig.end(), *it); if(it2 == orig.end()) orig.addObject(*it); } } /* else if(flags == SelectionFlags::ADD) */ else if(flags == SelectionFlags::REMOVE) { for(ObjectList::const_iterator it = newobjs.begin(); it != newobjs.end(); ++it) { ObjectList::iterator it2 = std::find(orig.begin(), orig.end(), *it); if(it2 != orig.end()) orig.erase(it2); } } /* else if(flags == SelectionFlags::REMOVE) */ }
bool SmartAI::IsEscortInvokerInRange() { ObjectList* targets = GetScript()->GetTargetList(SMART_ESCORT_TARGETS); if (targets) { if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin()))) { Player* player = (*targets->begin())->ToPlayer(); if (me->GetDistance(player) <= SMART_ESCORT_MAX_PLAYER_DIST) return true; if (Group* group = player->GetGroup()) { for (GroupReference* groupRef = group->GetFirstMember(); groupRef != NULL; groupRef = groupRef->next()) { Player* groupGuy = groupRef->getSource(); if (me->GetDistance(groupGuy) <= SMART_ESCORT_MAX_PLAYER_DIST) return true; } } }else { for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); iter++) { if (GetScript()->IsPlayer((*iter))) { if (me->GetDistance((*iter)->ToPlayer()) <= SMART_ESCORT_MAX_PLAYER_DIST) return true; } } } } return true;//escort targets were not set, ignore range check }
void SmartAI::EndPath(bool fail) { GetScript()->ProcessEventsFor(SMART_EVENT_WAYPOINT_ENDED, NULL, mLastWP->id, GetScript()->GetPathId()); RemoveEscortState(SMART_ESCORT_ESCORTING | SMART_ESCORT_PAUSED | SMART_ESCORT_RETURNING); mWayPoints = NULL; mCurrentWPID = 0; mWPPauseTimer = 0; mLastWP = NULL; if (mCanRepeatPath) StartPath(mRun, GetScript()->GetPathId(), mCanRepeatPath); else GetScript()->SetPathId(0); ObjectList* targets = GetScript()->GetTargetList(SMART_ESCORT_TARGETS); if (targets && mEscortQuestID) { if (targets->size() == 1 && GetScript()->IsPlayer((*targets->begin()))) { Player* plr = (*targets->begin())->ToPlayer(); if(!fail && plr->IsAtGroupRewardDistance(me) && !plr->GetCorpse()) plr->GroupEventHappens(mEscortQuestID, me); if(fail && plr->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE) plr->FailQuest(mEscortQuestID); if (Group *pGroup = plr->GetGroup()) { for (GroupReference *gr = pGroup->GetFirstMember(); gr != NULL; gr = gr->next()) { Player *pGroupGuy = gr->getSource(); if(!fail && pGroupGuy->IsAtGroupRewardDistance(me) && !pGroupGuy->GetCorpse()) pGroupGuy->AreaExploredOrEventHappens(mEscortQuestID); if(fail && pGroupGuy->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE) pGroupGuy->FailQuest(mEscortQuestID); } } }else { for (ObjectList::iterator iter = targets->begin(); iter != targets->end(); iter++) { if (GetScript()->IsPlayer((*iter))) { Player* plr = (*iter)->ToPlayer(); if(!fail && plr->IsAtGroupRewardDistance(me) && !plr->GetCorpse()) plr->AreaExploredOrEventHappens(mEscortQuestID); if(fail && plr->GetQuestStatus(mEscortQuestID) == QUEST_STATUS_INCOMPLETE) plr->FailQuest(mEscortQuestID); } } } } if (mDespawnState == 1) StartDespawn(); }
void Player::filterCurSelectedObjects(ObjectList &selected_objs, int select_cnt_limit) const { int stats[ObjectType::SIZE] = {0, }; int my_unit_cnt = 0; for(ObjectList::const_iterator it = selected_objs.begin(); it != selected_objs.end(); ++it) { const ObjectPtr &obj = *it; stats[obj->getObjectType()]++; if(obj->getOwner() == this) my_unit_cnt++; } for(ObjectList::iterator it = selected_objs.begin(); it != selected_objs.end(); ) { const ObjectPtr &obj = *it; // if there are at least one selected unit, deselect non-unit objects. if(stats[ObjectType::Unit] > 0) { if(obj->getObjectType() != ObjectType::Unit) selected_objs.erase(it++); else ++it; } else if(my_unit_cnt != 0) { if(obj->getOwner() != this) selected_objs.erase(it++); else ++it; } else { ++it; } } /* for(ObjectList::iterator it = selected_objs.begin(); */ if(select_cnt_limit > 0) { ObjectList::iterator end = selected_objs.end(); ObjectList::iterator it = selected_objs.begin(); // skip first nth object for(int i = 0; i < select_cnt_limit && it != end; i++) ++it; // erase everything else while(it != end) selected_objs.erase(it++); } }
SFUtils::ObjectSet SFUtils::getAllInstanceEquivalent( Udm::Object object ) { Udm::Object archetype = getTopArchetype( object ); if ( archetype == Udm::null ) return ObjectSet(); ObjectList objectList; objectList.push_back( archetype ); for( ObjectList::iterator oblItr = objectList.begin() ; oblItr != objectList.end() ; (void)++oblItr ) { ObjectSet objectSet = oblItr->instances(); objectList.insert( objectList.end(), objectSet.begin(), objectSet.end() ); } return ObjectSet( objectList.begin(), objectList.end() ); }
void __fastcall TfraGroup::MultiSelByRefObject ( bool clear_prev ) { ObjectList objlist; LPU32Vec sellist; if (Scene->GetQueryObjects(objlist,OBJCLASS_GROUP,1,1,-1)){ for (ObjectIt it=objlist.begin(); it!=objlist.end(); it++){ LPCSTR N = ((CGroupObject*)*it)->RefName(); ObjectIt _F = Scene->FirstObj(OBJCLASS_GROUP); ObjectIt _E = Scene->LastObj(OBJCLASS_GROUP); for(;_F!=_E;_F++){ CGroupObject *_O = (CGroupObject *)(*_F); if((*_F)->Visible()&&_O->RefCompare(N)){ if (clear_prev){ _O->Select( false ); sellist.push_back((u32*)_O); }else{ if (!_O->Selected()) sellist.push_back((u32*)_O); } } } } std::sort (sellist.begin(),sellist.end()); sellist.erase (std::unique(sellist.begin(),sellist.end()),sellist.end()); std::random_shuffle (sellist.begin(),sellist.end()); int max_k = iFloor(float(sellist.size())/100.f*float(seSelPercent->Value)+0.5f); int k = 0; for (LPU32It o_it=sellist.begin(); k<max_k; o_it++,k++){ CGroupObject *_O = (CGroupObject *)(*o_it); _O->Select( true ); } } }
void ESceneGroupTool::UngroupObjects(bool bUndo) { ObjectList lst = m_Objects; int sel_cnt = 0; if (!lst.empty()) { bool bModif = false; for (ObjectIt it=lst.begin(); it!=lst.end(); ++it) { if ((*it)->Selected()) { sel_cnt++; CGroupObject* obj = dynamic_cast<CGroupObject*>(*it); VERIFY(obj); if (obj->CanUngroup(true)) { obj->UngroupObjects (); Scene->RemoveObject (obj,false,true); xr_delete (obj); bModif = true; }else ELog.DlgMsg (mtError,"Can't ungroup object: '%s'.",obj->Name); } } if (bUndo&&bModif) Scene->UndoSave(); } if (0==sel_cnt) ELog.Msg (mtError,"Nothing selected."); }
void fill_guard_tasks_basic(Statement stmt) { struct IsOmpTask : public Predicate<AST_t> { ScopeLink _sl; IsOmpTask(ScopeLink sl) :_sl(sl) { } bool do_(IsOmpTask::ArgType a) const { return is_pragma_custom_construct("omp", "task", a, _sl); } }; ObjectList<AST_t> tasks = stmt.get_ast().depth_subtrees(IsOmpTask(stmt.get_scope_link())); for (ObjectList<AST_t>::iterator it = tasks.begin(); it != tasks.end(); it++) { PragmaCustomConstruct task_construct(*it, stmt.get_scope_link()); GuardedTask guarded_task(task_construct); _guarded_task_list.append(guarded_task); _num_tasks++; } }
void CGroupObject::GroupObjects(ObjectList& lst) { R_ASSERT(lst.size()); for (ObjectIt it=lst.begin(); it!=lst.end(); it++) LL_AppendObject(*it,true); UpdatePivot(0,false); }
bool Tutorial::isContainerEmpty(uint64 containerId) { bool empty = false; if (containerId == mContainerEventId) { Container* container = dynamic_cast<Container*>(gWorldManager->getObjectById(containerId)); if (container) { uint32 objectCount = 0; ObjectList* objList = container->getObjects(); ObjectList::iterator it = objList->begin(); ObjectList::iterator cEnd = objList->end(); while(it != cEnd) { if((*it)->getPrivateOwner() == this->getPlayer()) ++objectCount; ++it; } empty = (objectCount == 0); } } return empty; }
//========================================================================================= // // removes all structures items for a player // call this when destroying a building // void SpatialIndexManager::removeStructureItemsForPlayer(PlayerObject* player, BuildingObject* building) { DLOG(info) << "SpatialIndexManager::removeStructureItemsForPlayer:: : " << player->getId(); ObjectList cellObjects = building->getAllCellChilds(); ObjectList::iterator objIt = cellObjects.begin(); while(objIt != cellObjects.end()) { Object* object = (*objIt); if(PlayerObject* otherPlayer = dynamic_cast<PlayerObject*>(object)) { //do nothing players and creatures are always in the grid } else if(CreatureObject* pet = dynamic_cast<CreatureObject*>(object)) { //do nothing players and creatures are always in the grid } else { if((object) && (object->checkRegisteredWatchers(player))) { gContainerManager->unRegisterPlayerFromContainer(object,player); gMessageLib->sendDestroyObject(object->getId(), player); } } objIt++; } }
//====================================================================================================================== // // send creates of the equipped items from player to player // iterates all inventory items of the source and sends creates to the target // bool MessageLib::sendEquippedItems(PlayerObject* srcObject,PlayerObject* targetObject) { if(!_checkPlayer(targetObject)) return(false); ObjectList* invObjects = srcObject->getEquipManager()->getEquippedObjects(); ObjectList::iterator invObjectsIt = invObjects->begin(); while(invObjectsIt != invObjects->end()) { // items if(Item* item = dynamic_cast<Item*>(*invObjectsIt)) { if(item->getParentId() == srcObject->getId()) { gMessageLib->sendCreateTangible(item,targetObject); } else { gLogger->log(LogManager::DEBUG,"MessageLib send equipped objects: Its not equipped ... %I64u",item->getId()); } } ++invObjectsIt; } return(true); }
static void get_inout_decl(ObjectList<OutlineDataItem*>& data_items, std::string &in_type, std::string &out_type) { in_type = ""; out_type = ""; for (ObjectList<OutlineDataItem*>::iterator it = data_items.begin(); it != data_items.end(); it++) { const ObjectList<OutlineDataItem::CopyItem> &copies = (*it)->get_copies(); if (!copies.empty()) { Scope scope = (*it)->get_symbol().get_scope(); if (copies.front().directionality == OutlineDataItem::COPY_IN && in_type == "") { in_type = (*it)->get_field_type().get_simple_declaration(scope, ""); } else if (copies.front().directionality == OutlineDataItem::COPY_OUT && out_type == "") { out_type = (*it)->get_field_type().get_simple_declaration(scope, ""); } else if (copies.front().directionality == OutlineDataItem::COPY_INOUT) { //If we find an inout, set both input and output types and return out_type = (*it)->get_field_type().get_simple_declaration(scope, ""); in_type = out_type; return; } } } }
void SpatialIndexManager::initObjectsInRange(PlayerObject* player) { uint64_t player_id = player->getParentId(); if (player_id == 0) { return; } Object* tmp = gWorldManager->getObjectById(player_id); if (tmp->getType() != ObjType_Cell) { return; } CellObject* cell = static_cast<CellObject*>(tmp); tmp = gWorldManager->getObjectById(cell->getParentId()); if (tmp->getType() != ObjType_Building) { return; } BuildingObject* building = static_cast<BuildingObject*>(tmp); ObjectList children = building->getAllCellChilds(); std::for_each(children.begin(), children.end(), [this, player] (Object* cell_child) { if (cell_child->getType() != ObjType_Tangible) { return; } sendCreateObject(cell_child, player, true); }); }
void SectorManager::RunSectorEventThread() { m_SectorThreadRunning = true; unsigned long current_tick; long sleep_time; unsigned long check_tick = m_SectorID; ObjectList stations; ObjectList::iterator itrOList; if (m_ObjectMgr == (0)) return; ObjectList * mob_list; long mob_index = 0; //TODO: don't need an object manager for stations, but we do need an event thread. if (m_SectorID < 9999) { mob_list = m_ObjectMgr->GetMOBList(); m_ObjectMgr->SectorSetup(stations); m_ObjectMgr->SetSectorManager(this); } do { current_tick = GetNet7TickCount(); if (m_SectorID < 9999) //only MOBs and object effects for space & planet sectors { ProcessMOBs(current_tick, check_tick, true); //send station broadcasts for (itrOList = stations.begin(); itrOList != stations.end(); ++itrOList) { (*itrOList)->SendSoundBroadcast(check_tick); } } if (m_PlayerCount > 0) //only need to process timeslots if there are players present (for now - interacting MOBs will require time slots) { //first make the event calls for this node CallSlotEvents(m_EventSlotIndex); CallLongTermEvents(m_EventSlotIndex); //increment the slot index m_EventSlotIndex++; if (m_EventSlotIndex == (TIMESLOT_DURATION*10)) m_EventSlotIndex = 0; } check_tick++; sleep_time = current_tick - GetNet7TickCount() + SECTOR_THREAD_INTERVAL; if (check_tick > 128) check_tick = 0; if (sleep_time < 0) sleep_time = 0; Sleep(sleep_time); } while (!g_ServerShutdown); m_SectorThreadRunning = false; }
void excludeByType( ObjectList& list, const Set& set ) { for( auto it=list.begin(); it != list.end(); ) { if( set.count( (*it)->type() ) > 0 ) { it=list.erase( it ); } else { ++it; } } }
void dtProceed() { for (ComplexList::iterator i = complexList.begin(); i != complexList.end(); ++i) (*i)->proceed(); for (ObjectList::const_iterator j = objectList.begin(); j != objectList.end(); ++j) (*j).second->proceed(); }
//------------------------------------------------------------------------------------ // moving //------------------------------------------------------------------------------------ bool __fastcall TUI_CustomControl::MovingStart(TShiftState Shift) { ObjClassID cls = LTools->CurrentClassID(); if(Shift==ssRBOnly){ ExecCommand(COMMAND_SHOWCONTEXTMENU,parent_tool->ClassID); return false;} if(Scene->SelectionCount(true,cls)==0) return false; if (Shift.Contains(ssCtrl)){ ObjectList lst; if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)){ if (lst.size()==1){ Fvector p,n; UI->IR_GetMousePosReal(Device.m_hRenderWnd, UI->m_CurrentCp); Device.m_Camera.MouseRayFromPoint(UI->m_CurrentRStart,UI->m_CurrentRNorm,UI->m_CurrentCp); if (LUI->PickGround(p,UI->m_CurrentRStart,UI->m_CurrentRNorm,1,&n)){ for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) (*_F)->MoveTo(p,n); Scene->UndoSave(); } }else{ Fvector p,n; Fvector D={0,-1,0}; for(ObjectIt _F = lst.begin();_F!=lst.end();_F++){ if (LUI->PickGround(p,(*_F)->PPosition,D,1,&n)){ (*_F)->MoveTo(p,n); } } } } return false; }else{ if (etAxisY==Tools->GetAxis()){ m_MovingXVector.set(0,0,0); m_MovingYVector.set(0,1,0); }else{ m_MovingXVector.set( Device.m_Camera.GetRight() ); m_MovingXVector.y = 0; m_MovingYVector.set( Device.m_Camera.GetDirection() ); m_MovingYVector.y = 0; m_MovingXVector.normalize_safe(); m_MovingYVector.normalize_safe(); } m_MovingReminder.set(0,0,0); } return true; }
::Aurora::NWScript::ObjectSearch *ObjectContainer::findObjectsByType(ObjectType type) const { static const ObjectList kEmptyObjectList; ObjectMap::const_iterator l = _objects.find(type); if (l == _objects.end()) return new SearchType(kEmptyObjectList.begin(), kEmptyObjectList.end()); return new SearchType(l->second); }
DtCount dtTest() { move(); DtCount count = 0; if (caching) { for (ProxList::iterator i = proxList.begin(); i != proxList.end(); ++i) if (object_test((Encounter &)*i)) ++count; } else { for (ObjectList::const_iterator j = objectList.begin(); j != objectList.end(); ++j) for (ObjectList::const_iterator i = objectList.begin(); i != j; ++i) { Encounter e((*i).second, (*j).second); if (object_test(e)) ++count; } } return count; }
int SuitableAlignmentVisitor::join_list( ObjectList<int>& list ) { int result = 0; for( ObjectList<int>::iterator it = list.begin( ); it != list.end( ); ++it ) { result = result + ( *it ); } return result; }
void __fastcall TUI_CustomControl::MovingProcess(TShiftState _Shift) { Fvector amount; if (DefaultMovingProcess(_Shift,amount)){ ObjectList lst; if (Scene->GetQueryObjects(lst,LTools->CurrentClassID(),1,1,0)) for(ObjectIt _F = lst.begin();_F!=lst.end();_F++) (*_F)->Move(amount); } }
//! Method that inserts the PCFG corresponding to a function call void ExtensibleGraph::nest_pcfgs_rec( Node* current, ObjectList<ExtensibleGraph*>* pcfgs, unsigned int& min_id ) { if( !current->is_visited( ) ) { current->set_visited( true ); if( current->is_exit_node( ) ) return; if( current->is_graph_node( ) ) { // Inline inner nodes, if there is any inner function call nest_pcfgs_rec( current->get_graph_entry_node( ), pcfgs, min_id ); } else if( current->is_function_call_node( ) ) { // Look for the graph in the list of created pcfgs ExtensibleGraph* pcfg = NULL; Nodecl::FunctionCall called_func = current->get_statements( )[0].as<Nodecl::FunctionCall>( ); Symbol called_sym( called_func.get_called( ).get_symbol( ) ); std::cerr << "Called function: " << called_func.prettyprint( ) << std::endl; for( ObjectList<ExtensibleGraph*>::iterator it = pcfgs->begin( ); it != pcfgs->end( ) && pcfg == NULL; ++it ) { Symbol pcfg_sym( ( *it )->get_function_symbol( ) ); if( pcfg_sym.is_valid( ) ) { if( called_sym == pcfg_sym ) { pcfg = *it; } } } if( pcfg != NULL ) { // Copy the graph we want to embed, since we don't want to change the original ExtensibleGraph* new_nested_graph = pcfg->copy_graph( ); // Rename the id of the nodes to avoid having nodes with the same id new_nested_graph->rename_nodes_id( min_id ); // Create nodes containing temporary variables with the return values new_nested_graph->store_returns_in_temporary_vars( ); // Rename the parameters used in the copied graph with the corresponding arguments used in the call new_nested_graph->propagate_arguments_in_function_graph( called_func.get_arguments( ) ); Node* function_code_node = new_nested_graph->get_graph( )->get_graph_entry_node( )->get_children( )[0]; replace_node( current, function_code_node ); } } ObjectList<Node*> children = current->get_children( ); for( ObjectList<Node*>::iterator it = children.begin( ); it != children.end( ); ++it ) { nest_pcfgs_rec( *it, pcfgs, min_id ); } } }
void ClausesInfo::add_referenced_clause(AST_t directive, const ObjectList<std::string> & clause_names) { for(ObjectList<std::string>::const_iterator it = clause_names.begin(); it != clause_names.end(); ++it) { _directive_clauses_map[directive].referenced_clauses.append(*it); } }
void __fastcall TfraShape::ebDetachAllShapesClick(TObject *Sender) { ObjectList lst; if (Scene->GetQueryObjects(lst,OBJCLASS_SHAPE,1,1,0)){ Scene->SelectObjects(false,OBJCLASS_SHAPE); for (ObjectIt it=lst.begin(); it!=lst.end(); it++) ((CEditShape*)*it)->Detach(); } }
void __fastcall TfraWayPoint::ebConvert2Click(TObject *Sender) { ObjectList lst; int cnt = Scene->GetQueryObjects(lst, OBJCLASS_WAY, 1, 1, 0); for (ObjectIt it=lst.begin(); it!=lst.end(); it++) ((CWayObject*)(*it))->Convert2Link(); if (cnt) Scene->UndoSave(); ExecCommand(COMMAND_UPDATE_PROPERTIES); }
std::string to_string(const ObjectList<std::string>& t, const std::string& separator) { std::string result; for (ObjectList<std::string>::const_iterator it = t.begin(); it != t.end(); it++) { if (it != t.begin()) { result = result + separator; } result = result + (*it); } return result; }
std::string concat_strings(const ObjectList<_T>& string_list, const std::string& separator = "") { std::string result; for (typename ObjectList<_T>::const_iterator it = string_list.begin(); it != string_list.end(); it++) { if (it != string_list.begin()) { result += separator; } std::stringstream ss; ss << *it; result += ss.str(); } return result; }
void dtChangeVertexBase(DtShapeRef shape, const Point *base) { if (((Shape *)shape)->getType() == COMPLEX) ((Complex *)shape)->changeBase(base); for (ObjectList::const_iterator i = objectList.begin(); i != objectList.end(); ++i) { if ((*i).second->shapePtr == (Shape *)shape) { (*i).second->move(); } } }