Exemplo n.º 1
0
int Msg_Define::readAttr(Xml &xml, TiXmlNode *node){
	std::string key;
	XML_LOOP_BEGIN(node)
		key = xml.get_key(node);
		if(is_struct_member(key))
			setAttr(xml, node);
	XML_LOOP_END(node)
	return 0;
}
Exemplo n.º 2
0
void AI_Manager::init() {
	Xml xml;
	const Json::Value &server_misc = SERVER_CONFIG->server_misc();
	xml.load_xml(server_misc["ai_behavior_path"].asString().c_str());
	TiXmlNode *node = xml.get_root_node();
	XML_LOOP_BEGIN(node)
		std::string label = xml.get_key(node);
		int monster_id = xml.get_attr_int(node, "id");
		Behavior_Tree *tree = new Behavior_Tree(monster_id);
		tree->init(xml, xml.enter_node(node, label.c_str()));
		behavior_tree_map_[tree->monster_id()] = tree;
	XML_LOOP_END(node)
}
Exemplo n.º 3
0
int Msg_Define::setAttr(Xml &xml, TiXmlNode *node){
	std::string type, value, comt, sub1, sub2, key;
	std::string label = xml.get_key(node);
	if(label == "arg"){
		type = trans_to_base_name(xml.get_attr_str(node, "type"));
	}
	else if(label == "struct"){
		type = trans_to_base_name(xml.get_attr_str(node, "type"));
	}
	else if(label == "vector"){
		type = trans_to_base_name(label);
		sub1 = trans_to_base_name(xml.get_attr_str(node, "type"));
	}
	else if(label == "map"){
		type = trans_to_base_name(label);
		sub1 = trans_to_base_name(xml.get_attr_str(node, "key_type"));
		sub2 = trans_to_base_name(xml.get_attr_str(node, "type"));
		key = xml.get_attr_str(node, "key_name");
		
	}
	else if(label == "unordered_map"){
		type = trans_to_base_name(label);
		sub1 = trans_to_base_name(xml.get_attr_str(node, "key_type"));
		sub2 = trans_to_base_name(xml.get_attr_str(node, "type"));
		key = xml.get_attr_str(node, "key_name");
	}
	value = xml.get_attr_str(node, "name");
	if((comt = xml.get_attr_str(node, "desc")) != "" )
		comt = "//" + comt;
	typeName_.push_back(type);
	subType1_.push_back(sub1);
	subType2_.push_back(sub2);
	keyName_.push_back(key);
	valueName_.push_back(value);
	comment_.push_back(comt);
	return 0;
}