craftDecrementOrReplaceInput(input, output_replacements, replacements, gamedef);
}
-CraftHashType CraftDefinitionShaped::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;
-}
-
u64 CraftDefinitionShaped::getHash(CraftHashType type) const
{
assert(hash_inited); // Pre-condition
return;
hash_inited = true;
recipe_names = craftGetItemNames(recipe, gamedef);
+
+ bool has_group = false;
+ for (const auto &recipe_name : recipe_names) {
+ if (isGroupRecipeStr(recipe_name)) {
+ has_group = true;
+ break;
+ }
+ }
+ hash_type = has_group ? CRAFT_HASH_TYPE_COUNT : CRAFT_HASH_TYPE_ITEM_NAMES;
}
std::string CraftDefinitionShaped::dump() const
craftDecrementOrReplaceInput(input, output_replacements, replacements, gamedef);
}
-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;
-}
-
u64 CraftDefinitionShapeless::getHash(CraftHashType type) const
{
assert(hash_inited); // Pre-condition
hash_inited = true;
recipe_names = craftGetItemNames(recipe, gamedef);
std::sort(recipe_names.begin(), recipe_names.end());
+
+ bool has_group = false;
+ for (const auto &recipe_name : recipe_names) {
+ if (isGroupRecipeStr(recipe_name)) {
+ has_group = true;
+ break;
+ }
+ }
+ hash_type = has_group ? CRAFT_HASH_TYPE_COUNT : CRAFT_HASH_TYPE_ITEM_NAMES;
}
std::string CraftDefinitionShapeless::dump() const
craftDecrementOrReplaceInput(input, output_replacements, replacements, gamedef);
}
-CraftHashType CraftDefinitionCooking::getHashType() const
-{
- if (isGroupRecipeStr(recipe_name))
- return CRAFT_HASH_TYPE_COUNT;
-
- return CRAFT_HASH_TYPE_ITEM_NAMES;
-}
-
u64 CraftDefinitionCooking::getHash(CraftHashType type) const
{
if (type == CRAFT_HASH_TYPE_ITEM_NAMES) {
return;
hash_inited = true;
recipe_name = craftGetItemName(recipe, gamedef);
+
+ if (isGroupRecipeStr(recipe_name))
+ hash_type = CRAFT_HASH_TYPE_COUNT;
+ else
+ hash_type = CRAFT_HASH_TYPE_ITEM_NAMES;
}
std::string CraftDefinitionCooking::dump() const
craftDecrementOrReplaceInput(input, output_replacements, replacements, gamedef);
}
-CraftHashType CraftDefinitionFuel::getHashType() const
-{
- if (isGroupRecipeStr(recipe_name))
- return CRAFT_HASH_TYPE_COUNT;
-
- return CRAFT_HASH_TYPE_ITEM_NAMES;
-}
-
u64 CraftDefinitionFuel::getHash(CraftHashType type) const
{
if (type == CRAFT_HASH_TYPE_ITEM_NAMES) {
return;
hash_inited = true;
recipe_name = craftGetItemName(recipe, gamedef);
+
+ if (isGroupRecipeStr(recipe_name))
+ hash_type = CRAFT_HASH_TYPE_COUNT;
+ else
+ hash_type = CRAFT_HASH_TYPE_ITEM_NAMES;
}
+
std::string CraftDefinitionFuel::dump() const
{
std::ostringstream os(std::ios::binary);
virtual void decrementInput(CraftInput &input,
std::vector<ItemStack> &output_replacements, IGameDef *gamedef) const=0;
- virtual CraftHashType getHashType() const = 0;
+ CraftHashType getHashType() const
+ {
+ return hash_type;
+ }
virtual u64 getHash(CraftHashType type) const = 0;
// to be called after all mods are loaded, so that we catch all aliases
virtual void initHash(IGameDef *gamedef) = 0;
virtual std::string dump() const=0;
+
+protected:
+ CraftHashType hash_type;
};
/*
virtual void decrementInput(CraftInput &input,
std::vector<ItemStack> &output_replacements, IGameDef *gamedef) const;
- virtual CraftHashType getHashType() const;
virtual u64 getHash(CraftHashType type) const;
virtual void initHash(IGameDef *gamedef);
virtual void decrementInput(CraftInput &input,
std::vector<ItemStack> &output_replacements, IGameDef *gamedef) const;
- virtual CraftHashType getHashType() const;
virtual u64 getHash(CraftHashType type) const;
virtual void initHash(IGameDef *gamedef);
virtual void decrementInput(CraftInput &input,
std::vector<ItemStack> &output_replacements, IGameDef *gamedef) const;
- virtual CraftHashType getHashType() const { return CRAFT_HASH_TYPE_COUNT; }
virtual u64 getHash(CraftHashType type) const { return 2; }
- virtual void initHash(IGameDef *gamedef) {}
+ virtual void initHash(IGameDef *gamedef)
+ {
+ hash_type = CRAFT_HASH_TYPE_COUNT;
+ }
virtual std::string dump() const;
virtual void decrementInput(CraftInput &input,
std::vector<ItemStack> &output_replacements, IGameDef *gamedef) const;
- virtual CraftHashType getHashType() const;
virtual u64 getHash(CraftHashType type) const;
virtual void initHash(IGameDef *gamedef);
virtual void decrementInput(CraftInput &input,
std::vector<ItemStack> &output_replacements, IGameDef *gamedef) const;
- virtual CraftHashType getHashType() const;
virtual u64 getHash(CraftHashType type) const;
virtual void initHash(IGameDef *gamedef);