Beispiel #1
0
CraftHashType CraftDefinitionFuel::getHashType() const
{
	if (isGroupRecipeStr(recipe_name))
		return CRAFT_HASH_TYPE_COUNT;
	else
		return CRAFT_HASH_TYPE_ITEM_NAMES;
}
Beispiel #2
0
// Check if input matches recipe
// Takes recipe groups into account
static bool inputItemMatchesRecipe(const std::string &inp_name,
		const std::string &rec_name, IItemDefManager *idef)
{
	// Exact name
	if (inp_name == rec_name)
		return true;

	// Group
	if (isGroupRecipeStr(rec_name) && idef->isKnown(inp_name)) {
		const struct ItemDefinition &def = idef->get(inp_name);
		Strfnd f(rec_name.substr(6));
		bool all_groups_match = true;
		do {
			std::string check_group = f.next(",");
			if (itemgroup_get(def.groups, check_group) == 0) {
				all_groups_match = false;
				break;
			}
		} while (!f.atend());
		if (all_groups_match)
			return true;
	}

	// Didn't match
	return false;
}
Beispiel #3
0
CraftHashType CraftDefinitionShapeless::getHashType() const
{
	assert(hash_inited); // Pre-condition
	bool has_group = false;
	for (size_t i = 0; i < recipe_names.size(); i++) {
		if (isGroupRecipeStr(recipe_names[i])) {
			has_group = true;
			break;
		}
	}
	if (has_group)
		return CRAFT_HASH_TYPE_COUNT;
	else
		return CRAFT_HASH_TYPE_ITEM_NAMES;
}
Beispiel #4
0
CraftHashType CraftDefinitionShapeless::getHashType() const
{
	assert(hash_inited); // Pre-condition
	bool has_group = false;
	for (const auto &recipe_name : recipe_names) {
		if (isGroupRecipeStr(recipe_name)) {
			has_group = true;
			break;
		}
	}
	if (has_group)
		return CRAFT_HASH_TYPE_COUNT;

	return CRAFT_HASH_TYPE_ITEM_NAMES;
}