Exemplo n.º 1
0
constants_loader::constants_loader(wml::const_node_ptr node) : same_as_base_(false)
{
	constants_map m;
	if(node) {
		for(wml::node::const_attr_iterator i = node->begin_attr(); i != node->end_attr(); ++i) {
			const std::string& attr = i->first;
			if(std::find_if(attr.begin(), attr.end(), islower) != attr.end()) {
				//only all upper case are loaded as consts
				continue;
			}

			m[attr].serialize_from_string(i->second);
		}
	}

	if(constants_stack.empty() == false && constants_stack.back() == m) {
		same_as_base_ = true;
	} else if(constants_stack.empty() == false) {
		std::cerr << "CONSTANTS ARE DIFFERENT: ";
		for(constants_map::const_iterator i = m.begin(); i != m.end(); ++i) {
			if(constants_stack.back().count(i->first) == 0) {
				std::cerr << "NOT FOUND " << i->first << " ";
			} else if(i->second != constants_stack.back()[i->first]) {
				std::cerr << "DIFF " << i->first << " ";
			}
		}

		const constants_map& m2 = constants_stack.back();
		for(constants_map::const_iterator i = m2.begin(); i != m2.end(); ++i) {
			if(m.count(i->first) == 0) {
				std::cerr << "INSERTED " << i->first << " ";
			}
		}

		std::cerr << "\n";
	}

	//std::cerr << "ADD CONSTANTS_STACK ";
	for(constants_map::const_iterator i = m.begin(); i != m.end(); ++i) {
		std::cerr << i->first << " ";
	}

	if(m.begin() != m.end()) {
		std::cerr << "\n";
	}

	constants_stack.push_back(m);
}
Exemplo n.º 2
0
void load(const wml::const_node_ptr& node)
{
	for(wml::node::const_attr_iterator i = node->begin_attr();
	    i != node->end_attr(); ++i) {
		stat_calculation[i->first] = ptr(new formula(i->second));
	}

	wml::const_node_ptr penalties = node->get_child("ideal_strength_penalties");
	if(penalties) {
		for(wml::node::const_attr_iterator i = penalties->begin_attr();
		    i != penalties->end_attr(); ++i) {
			strength_penalty[i->first] = ptr(new formula(i->second));
		}
	}

	penalties = node->get_child("fatigue_penalties");
	if(penalties) {
		for(wml::node::const_attr_iterator i = penalties->begin_attr();
		    i != penalties->end_attr(); ++i) {
			fatigue_penalty[i->first] = ptr(new formula(i->second));
		}
	}

	wml::const_node_ptr height = node->get_child("height_advantage");
	if(height) {
		for(wml::node::const_attr_iterator i = height->begin_attr();
		    i != height->end_attr(); ++i) {
			height_advantage[i->first] = ptr(new formula(i->second));
		}
	}

	wml::const_node_ptr rules = node->get_child("rules");
	if(rules) {
		if(rules->has_attr("track")) {
			track_formula.reset(new formula((*rules)["track"]));
		}
	}
}
Exemplo n.º 3
0
void frame_draw_builder::init_from_wml(const wml::const_node_ptr& node) {
	for(wml::node::const_attr_iterator i = node->begin_attr();
	    i != node->end_attr(); ++i) {
		set_attr(i->first, i->second);
	}
}