Пример #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
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
}
Пример #3
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;
			}
		}
	}
Пример #4
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;
}
void f_unordered_multimap() {
  std::unordered_multimap<int, int> C;
  std::unordered_multimap<int, int>::iterator UMMapI1 = C.begin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto UMMapI1 = C.begin();

  const std::unordered_multimap<int, int> D;
  std::unordered_multimap<int, int>::const_iterator UMMapI2 = D.begin();
  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
  // CHECK-FIXES: auto UMMapI2 = D.begin();
}
Пример #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
	sf::RenderTexture* ShadowTextRenderer::findFromTextureCache(sf::Vector2u size)
	{
		auto it = shadowCache.find(size);

		if (it != shadowCache.end())
		{
			auto ptr = it->second;
			shadowCache.erase(it);
			return ptr;
		}

		return 0;
	}
Пример #8
0
	bool DataVariantTextPlain::parse
	(
		const Socket &sock,
		const std::chrono::milliseconds &timeout,
		std::string &str,
		const size_t leftBytes,
		const std::unordered_map<std::string, std::string> &params,
		std::unordered_multimap<std::string, std::string> &data,
		std::unordered_multimap<std::string, FileIncoming> &files
	)
	{
		if (str.empty() )
		{
			return true;
		}

		for (size_t var_pos = 0, var_end = 0; std::string::npos != var_end; var_pos = var_end + 1)
		{
			// Поиск следующего параметра
			var_end = str.find('&', var_pos);

			// Поиск значения параметра
			size_t delimiter = str.find('=', var_pos);

			if (delimiter >= var_end)
			{
				// Получить имя параметра
				std::string var_name = str.substr(var_pos, std::string::npos != var_end ? var_end - var_pos : std::string::npos);

				// Сохранить параметр с пустым значением
				data.emplace(std::move(var_name), "");
			}
			else
			{
				// Получить имя параметра
				std::string var_name = str.substr(var_pos, delimiter - var_pos);

				++delimiter;

				// Получить значение параметра
				std::string var_value = str.substr(delimiter, std::string::npos != var_end ? var_end - delimiter : std::string::npos);

				// Сохранить параметр и значение
				data.emplace(std::move(var_name), std::move(var_value) );
			}
		}

		str.clear();

		return true;
	}
Пример #9
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 ;
 }
Пример #10
0
	void rawFilesInfoToFilesIncoming(std::unordered_multimap<std::string, HttpServer::FileIncoming> &map, const Utils::raw_fileinfo raw[], const size_t count)
	{
		for (size_t i = 0; i < count; ++i)
		{
			map.emplace(raw[i].key ? raw[i].key : "", HttpServer::FileIncoming(raw[i].file_name, raw[i].file_type, raw[i].file_size) );
		}
	}
Пример #11
0
//calculate the given dynamical-network's maxminum B and its corresponding w
std::pair<int,double> calmaxBW(std::unordered_multimap<int,std::pair<int,int>> &SN)
{
  int maxB = 0,temp,attractor = 0;
  double Wn;
  for(auto it = SN.begin(); it != SN.end(); it++){
    if(it->first == it->second.first){
      temp = calBRec(SN,it->second.first);
      if(temp > maxB){
	maxB = temp;
	attractor = it->first;//main attractor
      }
    }
  }
  Wn = calWRec(SN,attractor,1,0);
  return std::make_pair(maxB,Wn/maxB);
}
Пример #12
0
CBaseModelInfo* GetModelInfo(uint32_t nameHash, int* mIdx)
{
	auto it = g_modelInfos.find(nameHash);

	if (it == g_modelInfos.end())
	{
		CBaseModelInfo* info = ((CBaseModelInfo*(*)(uint32_t, int*))0x98AAE0)(nameHash, mIdx);

		if (nameHash == HashRageString("parkgates_mh06"))
		{
//			__asm int 3
		}

		return info;
	}

	*mIdx = nameHash | 0xF0000000;

	auto indIt = g_modelInfoIdxTable.find(*mIdx);

	if (indIt == g_modelInfoIdxTable.end())
	{
		m_dependencyDrawableDicts.insert(std::make_pair(it->second->GetDrawblDict(), it->second.get()));
		g_modelInfoIdxTable.insert(std::make_pair(*mIdx, it->second));
	}

	return it->second.get();
}
Пример #13
0
int RequestEntityModel(CEntity* entity)
{
	auto entityExt = GetEntityExtensions()->GetAtPointer(entity);

	uint16_t txd = entityExt->modelInfo->GetTxd();
	uint16_t drawblDict = entityExt->modelInfo->GetDrawblDict();

	assert(drawblDict != 0xFFFF);

	if (txd != 0xFFFF)
	{
		RequestModel(txd, *(int*)0xF1CD84, 0);
	}

	if (drawblDict != 0xFFFF)
	{
		RequestModel(drawblDict, *(int*)0xF272E4, 0);
	}

	if (m_requestExistenceSet.find(entityExt->modelInfo) == m_requestExistenceSet.end())
	{
		//trace("request 0x%08x (drawable dict %s)\n", entityExt.modelInfo->GetModelHash(), GetStreamName(drawblDict, *(int*)0xF272E4).c_str());

		EntityRequest req;
		req.txd = txd;
		req.drawblDict = drawblDict;
		req.modelInfo = entityExt->modelInfo;
		m_requestList.push_back(req);
		m_requestExistenceSet.insert(entityExt->modelInfo);

		m_dependencyDictEnts.insert(std::make_pair(drawblDict, entity));
	}

	return 1;
}
Пример #14
0
//find the maximum B:basin for a given directed network
std::pair<int,double> findMaxBW(std::unordered_multimap<int,std::pair<int,int>> &SN,double *TF)
{
  int maxB = 0,temp,attractor = 0;
  double Wn;
  for(auto it = SN.begin(); it != SN.end(); it++){
    /**!!!!!!!!!!!your must change attractor!!!!!!!!**/
    if(it->first == it->second.first && it->first == 76){
      temp = findMaxBRec(SN,it->second.first,TF);
      if(temp > maxB){
	maxB = temp;
	attractor = it->first;//main attractor
      }
    }
  }
  Wn = calWRec(SN,attractor,1,0);
  return std::make_pair(maxB,Wn/maxB);
}
Пример #15
0
	void packFilesIncoming(
		std::vector<char> &buf,
		const std::unordered_multimap<std::string, Transfer::FileIncoming> &map
	) {
		packNumber(buf, map.size() );

		for (auto it = map.cbegin(); map.cend() != it; ++it) {
			packString(buf, it->first);

			const Transfer::FileIncoming &file = it->second;

			packString(buf, file.getTmpName() );
			packString(buf, file.getName() );
			packString(buf, file.getType() );
			packNumber(buf, file.getSize() );
		}
	}
Пример #16
0
 void operator()(msgpack::object::with_zone& o, const std::unordered_multimap<K, V, Hash, Compare, Alloc>& v) const {
     o.type = msgpack::type::MAP;
     if(v.empty()) {
         o.via.map.ptr  = nullptr;
         o.via.map.size = 0;
     } else {
         uint32_t size = checked_get_container_size(v.size());
         msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
         msgpack::object_kv* const pend = p + size;
         o.via.map.ptr  = p;
         o.via.map.size = size;
         typename std::unordered_multimap<K, V, Hash, Compare, Alloc>::const_iterator it(v.begin());
         do {
             p->key = msgpack::object(it->first, o.zone);
             p->val = msgpack::object(it->second, o.zone);
             ++p;
             ++it;
         } while(p < pend);
     }
 }
Пример #17
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;
}
Пример #18
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;
}
Пример #19
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;
}
Пример #20
0
	void filesIncomingToRawFilesInfo(Utils::raw_fileinfo *raw[], const std::unordered_multimap<std::string, HttpServer::FileIncoming> &map)
	{
		if (raw && map.size() )
		{
			raw_fileinfo *arr = new raw_fileinfo[map.size()];

			*raw = arr;

			size_t i = 0;

			for (auto it = map.cbegin(); map.cend() != it; ++it, ++i)
			{
				arr[i].key = stlStringToPChar(it->first);

				const HttpServer::FileIncoming &file = it->second;

				arr[i].file_name = stlStringToPChar(file.getName() );
				arr[i].file_type = stlStringToPChar(file.getType() );
				arr[i].file_size = file.getSize();
			}
		}
	}
Пример #21
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;
}
Пример #22
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;
}
Пример #24
0
 inline std::string PrettyPrint(const std::unordered_multimap<A, B, Hash, Predicate, Allocator>& maptoprint, const bool add_delimiters=false, const std::string& separator=", ")
 {
     std::ostringstream strm;
     if (maptoprint.size() > 0)
     {
         if (add_delimiters)
         {
             strm << "{";
             typename std::unordered_multimap<A, B, Hash, Predicate, Allocator>::const_iterator itr;
             for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
             {
                 std::pair<A, B> cur_pair(itr->first, itr->second);
                 if (itr != maptoprint.begin())
                 {
                     strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
             }
             strm << "}";
         }
         else
         {
             typename std::unordered_multimap<A, B, Hash, Predicate, Allocator>::const_iterator itr;
             for (itr = maptoprint.begin(); itr != maptoprint.end(); ++itr)
             {
                 std::pair<A, B> cur_pair(itr->first, itr->second);
                 if (itr != maptoprint.begin())
                 {
                     strm << separator << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
                 else
                 {
                     strm << PrettyPrint(cur_pair, add_delimiters, separator);
                 }
             }
         }
     }
     return strm.str();
 }
Пример #25
0
	bool parseCookies(const std::string &cookieHeader, std::unordered_multimap<std::string, std::string> &cookies)
	{
		if (cookieHeader.empty() )
		{
			return true;
		}

		for (size_t cur_pos = 0, next_value; std::string::npos != cur_pos; cur_pos = next_value)
		{
			next_value = cookieHeader.find(';', cur_pos);

			size_t delimiter = cookieHeader.find('=', cur_pos);

			if (std::string::npos == delimiter || delimiter > next_value)
			{
				return false;
			}

			std::string key = cookieHeader.substr(cur_pos, delimiter - cur_pos);
			trim(key);
			key = urlDecode(key);

			++delimiter;

			std::string value = cookieHeader.substr(delimiter, std::string::npos != next_value ? next_value - delimiter : next_value);
			trim(value);
			value = urlDecode(value);

			cookies.emplace(std::move(key), std::move(value) );

			if (std::string::npos != next_value)
			{
				++next_value;
			}
		}

		return true;
	}
Пример #26
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);
     }
   }
 }
Пример #27
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);
     }
   }
 }
Пример #28
0
void LoadDBCStores(const std::string& dataPath)
{
    uint32 oldMSTime = getMSTime();

    std::string dbcPath = dataPath + "dbc/";

    StoreProblemList bad_dbc_files;
    uint32 availableDbcLocales = 0xFFFFFFFF;

#define LOAD_DBC(store, file) LoadDBC(availableDbcLocales, bad_dbc_files, store, dbcPath, file)

    LOAD_DBC(sAreaTableStore,                     "AreaTable.dbc");
    LOAD_DBC(sAchievementCriteriaStore,           "Achievement_Criteria.dbc");
    LOAD_DBC(sAreaTriggerStore,                   "AreaTrigger.dbc");
    LOAD_DBC(sAreaGroupStore,                     "AreaGroup.dbc");
    LOAD_DBC(sAreaPOIStore,                       "AreaPOI.dbc");
    LOAD_DBC(sAuctionHouseStore,                  "AuctionHouse.dbc");
    LOAD_DBC(sBankBagSlotPricesStore,             "BankBagSlotPrices.dbc");
    LOAD_DBC(sBannedAddOnsStore,                  "BannedAddOns.dbc");
    LOAD_DBC(sBattlemasterListStore,              "BattlemasterList.dbc");
    LOAD_DBC(sBarberShopStyleStore,               "BarberShopStyle.dbc");
    LOAD_DBC(sCharacterFacialHairStylesStore,     "CharacterFacialHairStyles.dbc");
    LOAD_DBC(sCharSectionsStore,                  "CharSections.dbc");
    LOAD_DBC(sCharStartOutfitStore,               "CharStartOutfit.dbc");
    LOAD_DBC(sCharTitlesStore,                    "CharTitles.dbc");
    LOAD_DBC(sChatChannelsStore,                  "ChatChannels.dbc");
    LOAD_DBC(sChrClassesStore,                    "ChrClasses.dbc");
    LOAD_DBC(sChrRacesStore,                      "ChrRaces.dbc");
    LOAD_DBC(sCinematicCameraStore,               "CinematicCamera.dbc");
    LOAD_DBC(sCinematicSequencesStore,            "CinematicSequences.dbc");
    LOAD_DBC(sCreatureDisplayInfoStore,           "CreatureDisplayInfo.dbc");
    LOAD_DBC(sCreatureDisplayInfoExtraStore,      "CreatureDisplayInfoExtra.dbc");
    LOAD_DBC(sCreatureFamilyStore,                "CreatureFamily.dbc");
    LOAD_DBC(sCreatureModelDataStore,             "CreatureModelData.dbc");
    LOAD_DBC(sCreatureSpellDataStore,             "CreatureSpellData.dbc");
    LOAD_DBC(sCreatureTypeStore,                  "CreatureType.dbc");
    LOAD_DBC(sCurrencyTypesStore,                 "CurrencyTypes.dbc");
    LOAD_DBC(sDestructibleModelDataStore,         "DestructibleModelData.dbc");
    LOAD_DBC(sDungeonEncounterStore,              "DungeonEncounter.dbc");
    LOAD_DBC(sDurabilityCostsStore,               "DurabilityCosts.dbc");
    LOAD_DBC(sDurabilityQualityStore,             "DurabilityQuality.dbc");
    LOAD_DBC(sEmotesStore,                        "Emotes.dbc");
    LOAD_DBC(sEmotesTextStore,                    "EmotesText.dbc");
    LOAD_DBC(sEmotesTextSoundStore,               "EmotesTextSound.dbc");
    LOAD_DBC(sFactionStore,                       "Faction.dbc");
    LOAD_DBC(sFactionTemplateStore,               "FactionTemplate.dbc");
    LOAD_DBC(sGameObjectDisplayInfoStore,         "GameObjectDisplayInfo.dbc");
    LOAD_DBC(sGemPropertiesStore,                 "GemProperties.dbc");
    LOAD_DBC(sGlyphPropertiesStore,               "GlyphProperties.dbc");
    LOAD_DBC(sGlyphSlotStore,                     "GlyphSlot.dbc");
    LOAD_DBC(sGtBarberShopCostBaseStore,          "gtBarberShopCostBase.dbc");
    LOAD_DBC(sGtCombatRatingsStore,               "gtCombatRatings.dbc");
    LOAD_DBC(sGtChanceToMeleeCritBaseStore,       "gtChanceToMeleeCritBase.dbc");
    LOAD_DBC(sGtChanceToMeleeCritStore,           "gtChanceToMeleeCrit.dbc");
    LOAD_DBC(sGtChanceToSpellCritBaseStore,       "gtChanceToSpellCritBase.dbc");
    LOAD_DBC(sGtChanceToSpellCritStore,           "gtChanceToSpellCrit.dbc");
    LOAD_DBC(sGtNPCManaCostScalerStore,           "gtNPCManaCostScaler.dbc");
    LOAD_DBC(sGtOCTClassCombatRatingScalarStore,  "gtOCTClassCombatRatingScalar.dbc");
    LOAD_DBC(sGtOCTRegenHPStore,                  "gtOCTRegenHP.dbc");
    //LOAD_DBC(sGtOCTRegenMPStore,                  "gtOCTRegenMP.dbc");       -- not used currently
    LOAD_DBC(sGtRegenHPPerSptStore,               "gtRegenHPPerSpt.dbc");
    LOAD_DBC(sGtRegenMPPerSptStore,               "gtRegenMPPerSpt.dbc");
    LOAD_DBC(sHolidaysStore,                      "Holidays.dbc");
    LOAD_DBC(sItemStore,                          "Item.dbc");
    LOAD_DBC(sItemBagFamilyStore,                 "ItemBagFamily.dbc");
    //LOAD_DBC(sItemDisplayInfoStore,               "ItemDisplayInfo.dbc");     -- not used currently
    //LOAD_DBC(sItemCondExtCostsStore,              "ItemCondExtCosts.dbc");
    LOAD_DBC(sItemExtendedCostStore,              "ItemExtendedCost.dbc");
    LOAD_DBC(sItemLimitCategoryStore,             "ItemLimitCategory.dbc");
    LOAD_DBC(sItemRandomPropertiesStore,          "ItemRandomProperties.dbc");
    LOAD_DBC(sItemRandomSuffixStore,              "ItemRandomSuffix.dbc");
    LOAD_DBC(sItemSetStore,                       "ItemSet.dbc");
    LOAD_DBC(sLFGDungeonStore,                    "LFGDungeons.dbc");
    LOAD_DBC(sLightStore,                         "Light.dbc");
    LOAD_DBC(sLiquidTypeStore,                    "LiquidType.dbc");
    LOAD_DBC(sLockStore,                          "Lock.dbc");
    LOAD_DBC(sMailTemplateStore,                  "MailTemplate.dbc");
    LOAD_DBC(sMapStore,                           "Map.dbc");
    LOAD_DBC(sMapDifficultyStore,                 "MapDifficulty.dbc");
    LOAD_DBC(sMovieStore,                         "Movie.dbc");
    LOAD_DBC(sNamesProfanityStore,                "NamesProfanity.dbc");
    LOAD_DBC(sNamesReservedStore,                 "NamesReserved.dbc");
    LOAD_DBC(sOverrideSpellDataStore,             "OverrideSpellData.dbc");
    LOAD_DBC(sPowerDisplayStore,                  "PowerDisplay.dbc");
    LOAD_DBC(sPvPDifficultyStore,                 "PvpDifficulty.dbc");
    LOAD_DBC(sQuestXPStore,                       "QuestXP.dbc");
    LOAD_DBC(sQuestFactionRewardStore,            "QuestFactionReward.dbc");
    LOAD_DBC(sQuestSortStore,                     "QuestSort.dbc");
    LOAD_DBC(sRandomPropertiesPointsStore,        "RandPropPoints.dbc");
    LOAD_DBC(sScalingStatDistributionStore,       "ScalingStatDistribution.dbc");
    LOAD_DBC(sScalingStatValuesStore,             "ScalingStatValues.dbc");
    LOAD_DBC(sSkillLineStore,                     "SkillLine.dbc");
    LOAD_DBC(sSkillLineAbilityStore,              "SkillLineAbility.dbc");
    LOAD_DBC(sSkillRaceClassInfoStore,            "SkillRaceClassInfo.dbc");
    LOAD_DBC(sSkillTiersStore,                    "SkillTiers.dbc");
    LOAD_DBC(sSoundEntriesStore,                  "SoundEntries.dbc");
    LOAD_DBC(sSpellCastTimesStore,                "SpellCastTimes.dbc");
    LOAD_DBC(sSpellCategoryStore,                 "SpellCategory.dbc");
    LOAD_DBC(sSpellDurationStore,                 "SpellDuration.dbc");
    LOAD_DBC(sSpellFocusObjectStore,              "SpellFocusObject.dbc");
    LOAD_DBC(sSpellItemEnchantmentStore,          "SpellItemEnchantment.dbc");
    LOAD_DBC(sSpellItemEnchantmentConditionStore, "SpellItemEnchantmentCondition.dbc");
    LOAD_DBC(sSpellRadiusStore,                   "SpellRadius.dbc");
    LOAD_DBC(sSpellRangeStore,                    "SpellRange.dbc");
    LOAD_DBC(sSpellRuneCostStore,                 "SpellRuneCost.dbc");
    LOAD_DBC(sSpellShapeshiftStore,               "SpellShapeshiftForm.dbc");
    LOAD_DBC(sStableSlotPricesStore,              "StableSlotPrices.dbc");
    LOAD_DBC(sSummonPropertiesStore,              "SummonProperties.dbc");
    LOAD_DBC(sTalentStore,                        "Talent.dbc");
    LOAD_DBC(sTalentTabStore,                     "TalentTab.dbc");
    LOAD_DBC(sTaxiNodesStore,                     "TaxiNodes.dbc");
    LOAD_DBC(sTaxiPathStore,                      "TaxiPath.dbc");
    LOAD_DBC(sTaxiPathNodeStore,                  "TaxiPathNode.dbc");
    LOAD_DBC(sTeamContributionPointsStore,        "TeamContributionPoints.dbc");
    LOAD_DBC(sTotemCategoryStore,                 "TotemCategory.dbc");
    LOAD_DBC(sTransportAnimationStore,            "TransportAnimation.dbc");
    LOAD_DBC(sTransportRotationStore,             "TransportRotation.dbc");
    LOAD_DBC(sVehicleStore,                       "Vehicle.dbc");
    LOAD_DBC(sVehicleSeatStore,                   "VehicleSeat.dbc");
    LOAD_DBC(sWMOAreaTableStore,                  "WMOAreaTable.dbc");
    LOAD_DBC(sWorldMapAreaStore,                  "WorldMapArea.dbc");
    LOAD_DBC(sWorldMapOverlayStore,               "WorldMapOverlay.dbc");
    LOAD_DBC(sWorldSafeLocsStore,                 "WorldSafeLocs.dbc");

#undef LOAD_DBC

#define LOAD_DBC_EXT(store, file, dbtable, dbformat, dbpk) LoadDBC(availableDbcLocales, bad_dbc_files, store, dbcPath, file, dbtable, dbformat, dbpk)

    LOAD_DBC_EXT(sAchievementStore,     "Achievement.dbc",      "achievement_dbc",      CustomAchievementfmt,     CustomAchievementIndex);
    LOAD_DBC_EXT(sSpellStore,           "Spell.dbc",            "spell_dbc",            CustomSpellEntryfmt,      CustomSpellEntryIndex);
    LOAD_DBC_EXT(sSpellDifficultyStore, "SpellDifficulty.dbc",  "spelldifficulty_dbc",  CustomSpellDifficultyfmt, CustomSpellDifficultyIndex);

#undef LOAD_DBC_EXT

    for (CharacterFacialHairStylesEntry const* entry : sCharacterFacialHairStylesStore)
        if (entry->Race && ((1 << (entry->Race - 1)) & RACEMASK_ALL_PLAYABLE) != 0) // ignore nonplayable races
            sCharFacialHairMap.insert({ entry->Race | (entry->Gender << 8) | (entry->Variation << 16), entry });

    for (CharSectionsEntry const* entry : sCharSectionsStore)
        if (entry->Race && ((1 << (entry->Race - 1)) & RACEMASK_ALL_PLAYABLE) != 0) // ignore nonplayable races
            sCharSectionMap.insert({ entry->GenType | (entry->Gender << 8) | (entry->Race << 16), entry });

    for (CharStartOutfitEntry const* outfit : sCharStartOutfitStore)
        sCharStartOutfitMap[outfit->Race | (outfit->Class << 8) | (outfit->Gender << 16)] = outfit;

    for (EmotesTextSoundEntry const* entry : sEmotesTextSoundStore)
        sEmotesTextSoundMap[EmotesTextSoundKey(entry->EmotesTextId, entry->RaceId, entry->SexId)] = entry;

    for (FactionEntry const* faction : sFactionStore)
    {
        if (faction->team)
        {
            SimpleFactionsList& flist = sFactionTeamMap[faction->team];
            flist.push_back(faction->ID);
        }
    }

    for (GameObjectDisplayInfoEntry const* info : sGameObjectDisplayInfoStore)
    {
        if (info->maxX < info->minX)
            std::swap(*(float*)(&info->maxX), *(float*)(&info->minX));
        if (info->maxY < info->minY)
            std::swap(*(float*)(&info->maxY), *(float*)(&info->minY));
        if (info->maxZ < info->minZ)
            std::swap(*(float*)(&info->maxZ), *(float*)(&info->minZ));
    }

    // fill data
    for (MapDifficultyEntry const* entry : sMapDifficultyStore)
        sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = MapDifficulty(entry->resetTime, entry->maxPlayers, entry->areaTriggerText[0] != '\0');

    for (NamesProfanityEntry const* namesProfanity : sNamesProfanityStore)
    {
        ASSERT(namesProfanity->Language < TOTAL_LOCALES || namesProfanity->Language == -1);
        std::wstring wname;
        bool conversionResult = Utf8toWStr(namesProfanity->Name, wname);
        ASSERT(conversionResult);

        if (namesProfanity->Language != -1)
            NamesProfaneValidators[namesProfanity->Language].emplace_back(wname, Trinity::regex::perl | Trinity::regex::icase | Trinity::regex::optimize);
        else
            for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
                NamesProfaneValidators[i].emplace_back(wname, Trinity::regex::perl | Trinity::regex::icase | Trinity::regex::optimize);
    }

    for (NamesReservedEntry const* namesReserved : sNamesReservedStore)
    {
        ASSERT(namesReserved->Language < TOTAL_LOCALES || namesReserved->Language == -1);
        std::wstring wname;
        bool conversionResult = Utf8toWStr(namesReserved->Name, wname);
        ASSERT(conversionResult);

        if (namesReserved->Language != -1)
            NamesReservedValidators[namesReserved->Language].emplace_back(wname, Trinity::regex::perl | Trinity::regex::icase | Trinity::regex::optimize);
        else
            for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
                NamesReservedValidators[i].emplace_back(wname, Trinity::regex::perl | Trinity::regex::icase | Trinity::regex::optimize);
    }

    for (PvPDifficultyEntry const* entry : sPvPDifficultyStore)
    {
        ASSERT(entry->bracketId < MAX_BATTLEGROUND_BRACKETS, "PvpDifficulty bracket (%d) exceeded max allowed value (%d)", entry->bracketId, MAX_BATTLEGROUND_BRACKETS);
    }

    for (SkillRaceClassInfoEntry const* entry : sSkillRaceClassInfoStore)
        if (sSkillLineStore.LookupEntry(entry->SkillId))
            SkillRaceClassInfoBySkill.emplace(entry->SkillId, entry);

    for (SkillLineAbilityEntry const* skillLine : sSkillLineAbilityStore)
    {
        SpellEntry const* spellInfo = sSpellStore.LookupEntry(skillLine->spellId);
        if (spellInfo && spellInfo->Attributes & SPELL_ATTR0_PASSIVE)
        {
            for (CreatureFamilyEntry const* cFamily : sCreatureFamilyStore)
            {
                if (skillLine->skillId != cFamily->skillLine[0] && skillLine->skillId != cFamily->skillLine[1])
                    continue;
                if (spellInfo->spellLevel)
                    continue;

                if (skillLine->AutolearnType != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
                    continue;

                sPetFamilySpellsStore[cFamily->ID].insert(spellInfo->Id);
            }
        }
    }

    // Create Spelldifficulty searcher
    for (SpellDifficultyEntry const* spellDiff : sSpellDifficultyStore)
    {
        SpellDifficultyEntry newEntry;
        memset(newEntry.SpellID, 0, 4*sizeof(uint32));
        for (uint8 x = 0; x < MAX_DIFFICULTY; ++x)
        {
            if (spellDiff->SpellID[x] <= 0 || !sSpellStore.LookupEntry(spellDiff->SpellID[x]))
            {
                if (spellDiff->SpellID[x] > 0)//don't show error if spell is <= 0, not all modes have spells and there are unknown negative values
                    TC_LOG_ERROR("sql.sql", "spelldifficulty_dbc: spell %i at field id:%u at spellid%i does not exist in SpellStore (spell.dbc), loaded as 0", spellDiff->SpellID[x], spellDiff->ID, x);
                newEntry.SpellID[x] = 0;//spell was <= 0 or invalid, set to 0
            }
            else
                newEntry.SpellID[x] = spellDiff->SpellID[x];
        }
        if (newEntry.SpellID[0] <= 0 || newEntry.SpellID[1] <= 0)//id0-1 must be always set!
            continue;

        for (uint8 x = 0; x < MAX_DIFFICULTY; ++x)
            if (newEntry.SpellID[x])
                sSpellMgr->SetSpellDifficultyId(uint32(newEntry.SpellID[x]), spellDiff->ID);
    }

    // create talent spells set
    for (TalentEntry const* talentInfo : sTalentStore)
    {
        for (uint8 j = 0; j < MAX_TALENT_RANK; ++j)
            if (talentInfo->RankID[j])
                sTalentSpellPosMap[talentInfo->RankID[j]] = TalentSpellPos(talentInfo->TalentID, j);
    }


    // prepare fast data access to bit pos of talent ranks for use at inspecting
    {
        // now have all max ranks (and then bit amount used for store talent ranks in inspect)
        for (TalentTabEntry const* talentTabInfo : sTalentTabStore)
        {
            // prevent memory corruption; otherwise cls will become 12 below
            if ((talentTabInfo->ClassMask & CLASSMASK_ALL_PLAYABLE) == 0)
                continue;

            // store class talent tab pages
            for (uint32 cls = 1; cls < MAX_CLASSES; ++cls)
                if (talentTabInfo->ClassMask & (1 << (cls - 1)))
                    sTalentTabPages[cls][talentTabInfo->tabpage] = talentTabInfo->TalentTabID;
        }
    }

    for (TaxiPathEntry const* entry : sTaxiPathStore)
        sTaxiPathSetBySource[entry->from][entry->to] = TaxiPathBySourceAndDestination(entry->ID, entry->price);

    uint32 pathCount = sTaxiPathStore.GetNumRows();
    // Calculate path nodes count
    std::vector<uint32> pathLength;
    pathLength.resize(pathCount);                           // 0 and some other indexes not used
    for (TaxiPathNodeEntry const* entry : sTaxiPathNodeStore)
    {
        if (pathLength[entry->PathID] < entry->NodeIndex + 1)
            pathLength[entry->PathID] = entry->NodeIndex + 1;
    }

    // Set path length
    sTaxiPathNodesByPath.resize(pathCount);                 // 0 and some other indexes not used
    for (uint32 i = 1; i < sTaxiPathNodesByPath.size(); ++i)
        sTaxiPathNodesByPath[i].resize(pathLength[i]);
    // fill data
    for (TaxiPathNodeEntry const* entry : sTaxiPathNodeStore)
        sTaxiPathNodesByPath[entry->PathID][entry->NodeIndex] = entry;

    // Initialize global taxinodes mask
    // include existed nodes that have at least single not spell base (scripted) path
    {
        std::set<uint32> spellPaths;
        for (SpellEntry const* sInfo : sSpellStore)
            for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j)
                if (sInfo->Effect[j] == SPELL_EFFECT_SEND_TAXI)
                    spellPaths.insert(sInfo->EffectMiscValue[j]);

        sTaxiNodesMask.fill(0);
        sOldContinentsNodesMask.fill(0);
        sHordeTaxiNodesMask.fill(0);
        sAllianceTaxiNodesMask.fill(0);
        sDeathKnightTaxiNodesMask.fill(0);
        for (TaxiNodesEntry const* node : sTaxiNodesStore)
        {
            TaxiPathSetBySource::const_iterator src_i = sTaxiPathSetBySource.find(node->ID);
            if (src_i != sTaxiPathSetBySource.end() && !src_i->second.empty())
            {
                bool ok = false;
                for (TaxiPathSetForSource::const_iterator dest_i = src_i->second.begin(); dest_i != src_i->second.end(); ++dest_i)
                {
                    // not spell path
                    if (dest_i->second.price || spellPaths.find(dest_i->second.ID) == spellPaths.end())
                    {
                        ok = true;
                        break;
                    }
                }

                if (!ok)
                    continue;
            }

            // valid taxi network node
            uint8  field   = (uint8)((node->ID - 1) / 32);
            uint32 submask = 1  <<  ((node->ID - 1) % 32);
            sTaxiNodesMask[field] |= submask;

            if (node->MountCreatureID[0] && node->MountCreatureID[0] != 32981)
                sHordeTaxiNodesMask[field] |= submask;
            if (node->MountCreatureID[1] && node->MountCreatureID[1] != 32981)
                sAllianceTaxiNodesMask[field] |= submask;
            if (node->MountCreatureID[0] == 32981 || node->MountCreatureID[1] == 32981)
                sDeathKnightTaxiNodesMask[field] |= submask;

            // old continent node (+ nodes virtually at old continents, check explicitly to avoid loading map files for zone info)
            if (node->map_id < 2 || node->ID == 82 || node->ID == 83 || node->ID == 93 || node->ID == 94)
                sOldContinentsNodesMask[field] |= submask;

            // fix DK node at Ebon Hold and Shadow Vault flight master
            if (node->ID == 315 || node->ID == 333)
                const_cast<TaxiNodesEntry*>(node)->MountCreatureID[1] = 32981;
        }
    }

    for (WMOAreaTableEntry const* entry : sWMOAreaTableStore)
        sWMOAreaInfoByTripple[WMOAreaTableKey(entry->rootId, entry->adtId, entry->groupId)] = entry;

    // error checks
    if (bad_dbc_files.size() >= DBCFileCount)
    {
        TC_LOG_ERROR("misc", "Incorrect DataDir value in worldserver.conf or ALL required *.dbc files (%d) not found by path: %sdbc", DBCFileCount, dataPath.c_str());
        exit(1);
    }
    else if (!bad_dbc_files.empty())
    {
        std::string str;
        for (StoreProblemList::iterator i = bad_dbc_files.begin(); i != bad_dbc_files.end(); ++i)
            str += *i + "\n";

        TC_LOG_ERROR("misc", "Some required *.dbc files (%u from %d) not found or not compatible:\n%s", (uint32)bad_dbc_files.size(), DBCFileCount, str.c_str());
        exit(1);
    }

    // Check loaded DBC files proper version
    if (!sAreaTableStore.LookupEntry(4987)         ||       // last area added in 3.3.5a
        !sCharTitlesStore.LookupEntry(177)         ||       // last char title added in 3.3.5a
        !sGemPropertiesStore.LookupEntry(1629)     ||       // last gem property added in 3.3.5a
        !sItemStore.LookupEntry(56806)             ||       // last client known item added in 3.3.5a
        !sItemExtendedCostStore.LookupEntry(2997)  ||       // last item extended cost added in 3.3.5a
        !sMapStore.LookupEntry(724)                ||       // last map added in 3.3.5a
        !sSpellStore.LookupEntry(80864)            )        // last added spell in 3.3.5a
    {
        TC_LOG_ERROR("misc", "You have _outdated_ DBC files. Please extract correct versions from current using client.");
        exit(1);
    }

    TC_LOG_INFO("server.loading", ">> Initialized %d data stores in %u ms", DBCFileCount, GetMSTimeDiffToNow(oldMSTime));

}
Пример #29
0
 void register_cb_(const PortStatus evt, const PortStatusCb &cb) override {
   std::lock_guard<std::mutex> lock(cb_map_mutex);
   // cannot use make_pair because of the reference
   cb_map.insert(std::pair<unsigned int, const PortStatusCb &>(
       static_cast<unsigned int>(evt), cb));
 }
Пример #30
0
 void add( ID id, const POINTER& c ) { components.emplace( id, c ); }