예제 #1
0
int parse_actor_boots (actor_types *act, xmlNode *cfg) {
	xmlNode *item;
	char errmsg[120];
	int ok, col_idx;
	boots_part *boots;

	if (cfg == NULL || cfg->children == NULL) return 0;
	
	col_idx = get_property (cfg, "color", "boots color", boots_color_dict);
	if (col_idx < 0) return 0;
	
	boots = &(act->boots[col_idx]);
	ok = 1;
	for (item = cfg->children; item; item = item->next) {
		if (item->type == XML_ELEMENT_NODE) {
			if (xmlStrcasecmp (item->name, "skin") == 0) {
				get_string_value (boots->boots_name, sizeof (boots->boots_name), item);
			} else if (xmlStrcasecmp (item->name, "glow") == 0) {
				int mode = find_description_index (glow_mode_dict, item->children->content, "glow mode");
				if (mode < 0) mode = GLOW_NONE;
				boots->glow = mode;
			} else {
				snprintf (errmsg, sizeof (errmsg), "unknown legs property \"%s\"", item->name);
				LogError (errmsg);
				ok = 0;
			}
		}
	}
	
	return ok;
}
예제 #2
0
int parse_actor_body_part (body_part *part, xmlNode *cfg, const char *part_name) {
	xmlNode *item;
	char errmsg[120];
	int ok = 1;

	if (cfg == NULL) return 0;
	
	for (item = cfg; item; item = item->next) {
		if (item->type == XML_ELEMENT_NODE) {
			if (xmlStrcasecmp (item->name, "model") == 0) {
				get_string_value (part->model_name, sizeof (part->model_name), item);
			} else if (xmlStrcasecmp (item->name, "skin") == 0) {
				get_string_value (part->skin_name, sizeof (part->skin_name), item);
			} else if (xmlStrcasecmp (item->name, "glow") == 0) {
				int mode = find_description_index (glow_mode_dict, item->children->content, "glow mode");
				if (mode < 0) mode = GLOW_NONE;
				part->glow = mode;
			} else {
				snprintf (errmsg, sizeof (errmsg), "unknown %s property \"%s\"", part_name, item->name);
				LogError (errmsg);
				ok = 0;
			}
		}
	}
	
	return ok;
}
예제 #3
0
int get_property (xmlNode *node, const char *prop, const char *desc, const dict_elem dict[]) {
	xmlAttr *attr;
	char errmsg[120];
	
	for (attr = node->properties; attr; attr = attr->next) {
		if (attr->type == XML_ATTRIBUTE_NODE && xmlStrcasecmp (attr->name, prop) == 0) {
			return find_description_index (dict,  attr->children->content, desc);
		}
	}
	
	snprintf (errmsg, sizeof(errmsg), "Unable to find property %s in node %s\n", prop, node->name);
	LogError (errmsg);
	return -1;
}
예제 #4
0
int parse_actor_weapon (actor_types *act, xmlNode *cfg) {
	xmlNode *item;
	char errmsg[120];
	int ok, type_idx;
	weapon_part *weapon;

	if (cfg == NULL || cfg->children == NULL) return 0;
	
	type_idx = get_property (cfg, "type", "weapon type", weapon_type_dict);
	if (type_idx < 0) return 0;
	
	weapon = &(act->weapon[type_idx]);
	ok = 1;
	for (item = cfg->children; item; item = item->next) {
		if (item->type == XML_ELEMENT_NODE) {
			if (xmlStrcasecmp (item->name, "model") == 0) {
				get_string_value (weapon->model_name, sizeof (weapon->model_name), item);
			} else if (xmlStrcasecmp (item->name, "skin") == 0) {
				get_string_value (weapon->skin_name, sizeof (weapon->skin_name), item);
			} else if (xmlStrcasecmp (item->name, "attack_up1") == 0) {
				get_string_value (weapon->attack_up1, sizeof (weapon->attack_up1), item);
			} else if (xmlStrcasecmp (item->name, "attack_up2") == 0) {
				get_string_value (weapon->attack_up2, sizeof (weapon->attack_up2), item);
			} else if (xmlStrcasecmp (item->name, "attack_down1") == 0) {
				get_string_value (weapon->attack_down1, sizeof (weapon->attack_down1), item);
			} else if (xmlStrcasecmp (item->name, "attack_down2") == 0) {
				get_string_value (weapon->attack_down2, sizeof (weapon->attack_down2), item);
			} else if (xmlStrcasecmp (item->name, "glow") == 0) {
				int mode = find_description_index (glow_mode_dict, item->children->content, "glow mode");
				if (mode < 0) mode = GLOW_NONE;
				weapon->glow = mode;
			} else {
				snprintf (errmsg, sizeof (errmsg), "unknown weapon property \"%s\"", item->name);
				LogError (errmsg);
				ok = 0;
			}
		}
	}
	
	return ok;
}
예제 #5
0
파일: asc.c 프로젝트: sorlok/Eternal-Lands
int get_property(const xmlNode *node, const char *prop, const char *desc,
	const dict_elem dict[])
{
	const xmlAttr *attr;

	if (!node)
	{
		LOG_ERROR("Node is null!");
		return 0;
	}

	for (attr = node->properties; attr; attr = attr->next)
	{
		if (attr->type == XML_ATTRIBUTE_NODE &&
			xmlStrcasecmp (attr->name, (const xmlChar*)prop) == 0)
		{
			return find_description_index(dict,
				(const char*)attr->children->content, desc);
		}
	}

	LOG_ERROR("Unable to find property %s in node %s\n", prop, node->name);
	return -1;
}