Пример #1
0
void PreFullReleaseModel(int streamingIdx)
{
	int drawblDict = *(int*)0xF272E4;

	if (streamingIdx >= GetTypeStart(drawblDict) && streamingIdx <= GetTypeEnd(drawblDict))
	{
		int dict = streamingIdx - GetTypeStart(drawblDict);

		auto pair = m_dependencyDrawableDicts.equal_range(dict);

		for (auto it = pair.first; it != pair.second; it++)
		{
			if (it->second->HasInstance())
			{
				//trace("releasing dict %s (0x%08x) for a full release because *reasons*\n", GetStreamName(dict, *(int*)0xF272E4).c_str(), it->second->GetModelHash());

				it->second->RemoveInstance();
			}
		}

		//m_dependencyDrawableDicts.erase(dict);

		auto entPair = m_dependencyDictEnts.equal_range(dict);

		for (auto it = entPair.first; it != entPair.second; it++)
		{
			//trace("also destroying model for dict %s\n", GetStreamName(dict, *(int*)0xF272E4).c_str());

			it->second->DestroyModel();
		}

		m_dependencyDictEnts.erase(dict);
	}
}
Пример #2
0
int DrawableDictStoreGetUsageWrap(int dict)
{
	int usage = DrawblDictGetUsage(dict);

	if (usage == 0 && _ReturnAddress() == (void*)0xBCC153)
	{
		bool deferred = false;

		auto pair = m_dependencyDrawableDicts.equal_range(dict);

		for (auto it = pair.first; it != pair.second; it++)
		{
			if (it->second->HasInstance())
			{
				if (!it->second->ShouldRelease())
				{
					//trace("model info for %s (0x%08x) still has %i references!\n", GetStreamName(dict, *(int*)0xF272E4).c_str(), it->second->GetModelHash(), it->second->GetRefCount());

					return 1;
				}

				it->second->RemoveInstance();

				deferred = true;
			}
		}

		//m_dependencyDrawableDicts.erase(dict);

		auto entPair = m_dependencyDictEnts.equal_range(dict);

		for (auto it = entPair.first; it != entPair.second; it++)
		{
			it->second->DestroyModel();

			deferred = true;
		}

		m_dependencyDictEnts.erase(dict);

		if (deferred)
		{
			//trace("pre-deferring drawable destruction for %s\n", GetStreamName(dict, *(int*)0xF272E4).c_str());

			DeferToNextFrame([=] ()
			{
				//trace("executing pre-deferred drawable destruction for %s\n", GetStreamName(dict, *(int*)0xF272E4).c_str());

				//ReleaseDrawblDict(dict);
				ReleaseStreamingObjectNow((void*)0xF21C60, dict + GetTypeStart(*(int*)0xF272E4));
			});

			return 1;
		}
	}

	return usage;
}
Пример #3
0
bool strIsInHashTable(RawString &str, std::hash<std::string> &strHash,
    std::unordered_multimap<u32, StringTableNode> &stringTable)
{
    u32 hash = strHash(str);
    int numMatching = stringTable.count(hash);
    if ( numMatching == 1 )
    { // Should guarentee that you can find at least one entry
        StringTableNode &node = stringTable.find(hash)->second;
        if ( node.string.compare(str) == 0 )
            return true;
    }
    else if ( numMatching > 1 )
    {
        u32 currLowest = 0;
        bool success = false;
        auto range = stringTable.equal_range(hash);
        for ( auto it = range.first; it != range.second; it ++ )
        {
            StringTableNode &node = it->second;
            if ( node.string.compare(str) == 0 )
            {
                if ( success == false ) // If no matches have previously been found
                {
                    currLowest = node.stringNum;
                    success = true;
                }
                else if ( node.stringNum < currLowest ) // If matches have previously been found
                    currLowest = node.stringNum; // Replace if stringNum < previous stringNum
            }
        }
        return success;
    }
    return false; // No matches
}
Пример #4
0
 std::vector<POINTER> get( ID id ) const
 {
     std::vector<POINTER> result ;
     auto pair = components.equal_range(id) ;
     for( auto iter = pair.first ; iter != pair.second ; ++iter ) result.push_back(iter->second) ;
     return result ;
 }
Пример #5
0
	void deregisterListener(const std::string& attributeName, std::function<void(EmberEntity&, const Atlas::Message::Element&)>& listener) {
		for (auto range = mCallbacks.equal_range(attributeName); range.first != range.second; ++range.first) {
			if (range.first->second == &listener) {
				mCallbacks.erase(range.first);
				break;
			}
		}
	}
Пример #6
0
PyArrayObject* get_keypoint_strokes(int keypointId, int instance)
{
	if(keypointsPixels.size() > 0)
	{
		std::pair <std::unordered_multimap<int,std::pair<int, int> >::iterator, std::unordered_multimap<int,std::pair<int, int>>::iterator> ret;
		ret = keypointsPixels.equal_range(keypoints[keypointId].class_id);

		npy_intp size_pts[2];
		size_pts[0] = std::distance(ret.first, ret.second);
		size_pts[1] = 2;
		PyArrayObject* out = (PyArrayObject *) PyArray_SimpleNew( 2, size_pts, NPY_OBJECT );
		int strokesCount = 0;

		for (std::unordered_multimap<int,std::pair<int, int> >::iterator it=ret.first; it!=ret.second; it++)
		{
			char* ptr = (char*) PyArray_GETPTR2(out, strokesCount, 0);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(it->second.first));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 1);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(it->second.second));
			strokesCount++;
		}
		return out;

	}

	std::vector<std::vector<cv::Ptr<StrokeDir> > >& strokes = instances[instance].segmenter->keypointStrokes[keypointId];
	npy_intp size_pts[2];
	int strokesCount = 0;
	for( size_t i = 0; i < strokes.size(); i++ )
	{
		strokesCount += strokes[i].size();
	}
	size_pts[0] = strokesCount;

	size_pts[1] = 4;
	PyArrayObject* out = (PyArrayObject *) PyArray_SimpleNew( 2, size_pts, NPY_OBJECT );
	strokesCount = 0;
	for( size_t i = 0; i < strokes.size(); i++ )
	{
		for( size_t j = 0; j < strokes[i].size(); j++ )
		{
			char* ptr = (char*) PyArray_GETPTR2(out, strokesCount, 0);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->center.x));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 1);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->center.y));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 2);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->direction.x));
			ptr = (char*) PyArray_GETPTR2(out, strokesCount, 3);
			PyArray_SETITEM(out, ptr, PyInt_FromLong(strokes[i][j]->direction.y));
			strokesCount++;
		}
	}
	return out;
}
Пример #7
0
//store every state-network node's B in "TF_B"
int calDeltaBRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,double *TF_B)
{
  int b = 1,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = calDeltaBRec(SN,it->second.first,TF_B);
      b += temp;
    }
  TF_B[start] = b;
  return b;
}
Пример #8
0
//calculate B recursion function
int calBRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start)
{
  int b = 1,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = calBRec(SN,it->second.first);
      b += temp;
      it->second.second = temp;//traffic flow
    }
  return b;
}
Пример #9
0
//store every state-network node's D in "TF_D"
int calDeltaDRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,double *TF_D)
{
  int d = 0,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = calDeltaDRec(SN,it->second.first,TF_D);
      d += 1;
      it->second.second = temp;//traffic flow
    }
  TF_D[start] = d;
  return d;
}
Пример #10
0
//calculate the <Wn>,and store the W for each attractor
double calWRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,int L,int total_trafic)
{
  int total_traffic2;
  double w = 0;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      total_traffic2 = total_trafic + it->second.second; //total traffic flow from it->second.second to the attractor
      w += (double)total_traffic2/L + calWRec(SN,it->second.first,L+1,total_traffic2);
    }
  //store the traffic flow!!!!this is not traffic flow!!!!!
  //TF[start] = w;
  return w;
}
Пример #11
0
//find maximum B recursion function
int findMaxBRec(std::unordered_multimap<int,std::pair<int,int>> &SN,int start,double *TF)
{
  int b = 1,temp;
  //int b = 0,temp;
  auto its = SN.equal_range(start);
  for (auto it = its.first; it != its.second; ++it)
    if(it->first != it->second.first){
      temp = findMaxBRec(SN,it->second.first,TF);
      b += temp;
      //findMaxBRec(SN,it->second.first,TF);
      //b += 1;
      it->second.second = temp;//traffic flow
    }
  TF[start] = b;
  return b;
}
size_t Relationships::_recurse(size_t src) {
  Person *dst;
  size_t height = 0;

  std::cerr << "visiting " << src << std::endl;
  for (auto pair = _edges.equal_range(src)
     ; pair.first != pair.second
     ; pair.first++) {
    dst = &_vertices[pair.first->second];
    if (!dst->visited)
      height = std::max(height, _recurse(pair.first->second));
    else
      height = std::max(height, dst->furthest_influencer);
  }
  _vertices[src].furthest_influencer = height + 1;
  _vertices[src].visited = true;
  std::cerr << "visiting " << src << "#DONE got: " << height + 1 << std::endl;
  return height + 1;
}
Пример #13
0
 void exclude_referenced_bridgee(DexMethod* code_method, const DexCode& code) {
   auto const& insts = code.get_instructions();
   for (auto inst : insts) {
     if (!is_invoke(inst->opcode())) continue;
     auto method = static_cast<DexOpcodeMethod*>(inst)->get_method();
     auto range = m_potential_bridgee_refs.equal_range(
         MethodRef(method->get_class(), method->get_name(),
             method->get_proto()));
     for (auto it = range.first; it != range.second; ++it) {
       auto referenced_bridge = it->second;
       // Don't count the bridge itself
       if (referenced_bridge == code_method) continue;
       TRACE(BRIDGE,
             5,
             "Rejecting, reference `%s.%s.%s' in `%s' blocks `%s'\n",
             SHOW(method->get_class()),
             SHOW(method->get_name()),
             SHOW(method->get_proto()),
             SHOW(code_method),
             SHOW(referenced_bridge));
       m_bridges_to_bridgees.erase(referenced_bridge);
     }
   }
 }
Пример #14
0
 void exclude_referenced_bridgee(DexMethod* code_method, IRCode& code) {
   for (auto& mie : InstructionIterable(&code)) {
     auto inst = mie.insn;
     if (!is_invoke(inst->opcode())) continue;
     auto method = inst->get_method();
     auto range = m_potential_bridgee_refs.equal_range(
         MethodRef(method->get_class(), method->get_name(),
             method->get_proto()));
     for (auto it = range.first; it != range.second; ++it) {
       auto referenced_bridge = it->second;
       // Don't count the bridge itself
       if (referenced_bridge == code_method) continue;
       TRACE(BRIDGE,
             5,
             "Rejecting, reference `%s.%s.%s' in `%s' blocks `%s'\n",
             SHOW(method->get_class()),
             SHOW(method->get_name()),
             SHOW(method->get_proto()),
             SHOW(code_method),
             SHOW(referenced_bridge));
       m_bridges_to_bridgees.erase(referenced_bridge);
     }
   }
 }
Пример #15
0
	void dispatchAttributeChange(EmberEntity& entity, const std::string& attributeName, const Atlas::Message::Element& value) {
		for (auto range = mCallbacks.equal_range(attributeName); range.first != range.second; ++range.first) {
			(*range.first->second)(entity, value);
		}
	}