コード例 #1
0
ファイル: entities.cpp プロジェクト: Insomniuhh/StatusSpec
bool Entities::RetrieveClassPropOffset(std::string className, std::vector<std::string> propertyTree) {
	std::string propertyString = ConvertTreeToString(propertyTree);

	if (classPropOffsets[className].find(propertyString) != classPropOffsets[className].end()) {
		return true;
	}

	ClientClass *cc = Interfaces::pClientDLL->GetAllClasses();

	while (cc) {
		if (className.compare(cc->GetName()) == 0) {
			RecvTable *table = cc->m_pRecvTable;

			int offset = 0;
			RecvProp *prop = nullptr;

			if (table) {
				for (auto iterator = propertyTree.begin(); iterator != propertyTree.end(); ++iterator) {
					int subOffset = 0;

					if (prop && prop->GetType() == DPT_DataTable) {
						table = prop->GetDataTable();
					}

					if (!table) {
						return false;
					}

					if (GetSubProp(table, iterator->c_str(), prop, subOffset)) {
						offset += subOffset;
					}
					else {
						return false;
					}

					table = nullptr;
				}

				classPropOffsets[className][propertyString] = offset;

				return true;
			}
		}
		cc = cc->m_pNext;
	}

	return false;
}
コード例 #2
0
ファイル: entities.cpp プロジェクト: Insomniuhh/StatusSpec
bool Entities::GetSubProp(RecvTable *table, const char *propName, RecvProp *&prop, int &offset) {
	for (int i = 0; i < table->GetNumProps(); i++) {
		offset = 0;

		RecvProp *currentProp = table->GetProp(i);

		if (strcmp(currentProp->GetName(), propName) == 0) {
			prop = currentProp;
			offset = currentProp->GetOffset();
			return true;
		}

		if (currentProp->GetType() == DPT_DataTable) {
			if (GetSubProp(currentProp->GetDataTable(), propName, prop, offset)) {
				offset += currentProp->GetOffset();
				return true;
			}
		}
	}

	return false;
}