Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
craftdef.cpp File Reference
#include "craftdef.h"
#include "irrlichttypes.h"
#include "log.h"
#include <sstream>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include "gamedef.h"
#include "inventory.h"
#include "util/serialize.h"
#include "util/string.h"
#include "util/numeric.h"
#include "util/strfnd.h"
#include "exceptions.h"
+ Include dependency graph for craftdef.cpp:

Classes

class  CCraftDefManager
 

Functions

bool isGroupRecipeStr (const std::string &rec_name)
 
static bool hasGroupItem (const std::vector< std::string > &recipe)
 
u64 getHashForString (const std::string &recipe_str)
 
static u64 getHashForGrid (CraftHashType type, const std::vector< std::string > &grid_names)
 
static bool inputItemMatchesRecipe (const std::string &inp_name, const std::string &rec_name, IItemDefManager *idef)
 
static std::string craftGetItemName (const std::string &itemstring, IGameDef *gamedef)
 
static std::vector< std::string > craftGetItemNames (const std::vector< std::string > &itemstrings, IGameDef *gamedef)
 
static std::vector< std::string > craftGetItemNames (const std::vector< ItemStack > &items, IGameDef *gamedef)
 
static std::vector< ItemStackcraftGetItems (const std::vector< std::string > &items, IGameDef *gamedef)
 
static bool craftGetBounds (const std::vector< std::string > &items, unsigned int width, unsigned int &min_x, unsigned int &max_x, unsigned int &min_y, unsigned int &max_y)
 
static void craftDecrementInput (CraftInput &input, IGameDef *gamedef)
 
static void craftDecrementOrReplaceInput (CraftInput &input, std::vector< ItemStack > &output_replacements, const CraftReplacements &replacements, IGameDef *gamedef)
 
static std::string craftDumpMatrix (const std::vector< std::string > &items, unsigned int width)
 
std::string craftDumpMatrix (const std::vector< ItemStack > &items, unsigned int width)
 
static bool hopcroft_karp_can_match_all (const std::vector< std::vector< u16 > > &bip_graph)
 
static ItemStack craftToolRepair (const ItemStack &item1, const ItemStack &item2, float additional_wear, IGameDef *gamedef)
 
IWritableCraftDefManagercreateCraftDefManager ()
 

Variables

constexpr u16 SHAPELESS_GROUPS_MAX = 30000
 

Function Documentation

◆ craftDecrementInput()

static void craftDecrementInput ( CraftInput & input,
IGameDef * gamedef )
static

References CraftInput::items.

Referenced by craftDecrementOrReplaceInput(), and CraftDefinitionToolRepair::decrementInput().

+ Here is the caller graph for this function:

◆ craftDecrementOrReplaceInput()

static void craftDecrementOrReplaceInput ( CraftInput & input,
std::vector< ItemStack > & output_replacements,
const CraftReplacements & replacements,
IGameDef * gamedef )
static

References craftDecrementInput(), ItemStack::deSerialize(), IGameDef::idef(), inputItemMatchesRecipe(), CraftInput::items, and CraftReplacements::pairs.

Referenced by CraftDefinitionCooking::decrementInput(), CraftDefinitionFuel::decrementInput(), CraftDefinitionShaped::decrementInput(), and CraftDefinitionShapeless::decrementInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ craftDumpMatrix() [1/2]

std::string craftDumpMatrix ( const std::vector< ItemStack > & items,
unsigned int width )

◆ craftDumpMatrix() [2/2]

static std::string craftDumpMatrix ( const std::vector< std::string > & items,
unsigned int width )
static

Referenced by CraftDefinitionShaped::dump(), CraftDefinitionShapeless::dump(), and CraftInput::dump().

+ Here is the caller graph for this function:

◆ craftGetBounds()

static bool craftGetBounds ( const std::vector< std::string > & items,
unsigned int width,
unsigned int & min_x,
unsigned int & max_x,
unsigned int & min_y,
unsigned int & max_y )
static

Referenced by CraftDefinitionShaped::check().

+ Here is the caller graph for this function:

◆ craftGetItemName()

static std::string craftGetItemName ( const std::string & itemstring,
IGameDef * gamedef )
static

References ItemStack::deSerialize(), IGameDef::idef(), and ItemStack::name.

Referenced by CraftDefinitionCooking::check(), CraftDefinitionFuel::check(), craftGetItemNames(), CraftDefinitionCooking::initHash(), CraftDefinitionFuel::initHash(), and CCraftDefManager::registerCraft().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ craftGetItemNames() [1/2]

static std::vector< std::string > craftGetItemNames ( const std::vector< ItemStack > & items,
IGameDef * gamedef )
static

◆ craftGetItemNames() [2/2]

static std::vector< std::string > craftGetItemNames ( const std::vector< std::string > & itemstrings,
IGameDef * gamedef )
static

References craftGetItemName().

Referenced by CraftDefinitionShaped::check(), CraftDefinitionShapeless::check(), CCraftDefManager::getCraftResult(), CraftDefinitionShaped::initHash(), and CraftDefinitionShapeless::initHash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ craftGetItems()

static std::vector< ItemStack > craftGetItems ( const std::vector< std::string > & items,
IGameDef * gamedef )
static

References IGameDef::getItemDefManager().

Referenced by CraftDefinitionCooking::getInput(), CraftDefinitionFuel::getInput(), CraftDefinitionShaped::getInput(), and CraftDefinitionShapeless::getInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ craftToolRepair()

static ItemStack craftToolRepair ( const ItemStack & item1,
const ItemStack & item2,
float additional_wear,
IGameDef * gamedef )
static

References ItemStack::count, IItemDefManager::get(), ItemDefinition::groups, IGameDef::idef(), ITEM_TOOL, itemgroup_get(), ItemStack::name, ItemDefinition::type, and ItemStack::wear.

Referenced by CraftDefinitionToolRepair::check(), and CraftDefinitionToolRepair::getOutput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createCraftDefManager()

IWritableCraftDefManager * createCraftDefManager ( )

◆ getHashForGrid()

static u64 getHashForGrid ( CraftHashType type,
const std::vector< std::string > & grid_names )
static

References CRAFT_HASH_TYPE_COUNT, CRAFT_HASH_TYPE_ITEM_NAMES, CRAFT_HASH_TYPE_UNHASHED, and getHashForString().

Referenced by CCraftDefManager::getCraftResult(), CraftDefinitionShaped::getHash(), and CraftDefinitionShapeless::getHash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHashForString()

u64 getHashForString ( const std::string & recipe_str)
inline

References murmur_hash_64_ua().

Referenced by CraftDefinitionCooking::getHash(), CraftDefinitionFuel::getHash(), and getHashForGrid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasGroupItem()

static bool hasGroupItem ( const std::vector< std::string > & recipe)
static

References isGroupRecipeStr().

Referenced by CraftDefinitionShaped::CraftDefinitionShaped(), CraftDefinitionShapeless::CraftDefinitionShapeless(), CraftDefinitionShaped::initHash(), and CraftDefinitionShapeless::initHash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hopcroft_karp_can_match_all()

static bool hopcroft_karp_can_match_all ( const std::vector< std::vector< u16 > > & bip_graph)
static

References SHAPELESS_GROUPS_MAX.

Referenced by CraftDefinitionShapeless::check().

+ Here is the caller graph for this function:

◆ inputItemMatchesRecipe()

static bool inputItemMatchesRecipe ( const std::string & inp_name,
const std::string & rec_name,
IItemDefManager * idef )
static

References BasicStrfnd< T >::at_end(), IItemDefManager::get(), ItemDefinition::groups, isGroupRecipeStr(), IItemDefManager::isKnown(), itemgroup_get(), and BasicStrfnd< T >::next().

Referenced by CraftDefinitionCooking::check(), CraftDefinitionFuel::check(), CraftDefinitionShaped::check(), CraftDefinitionShapeless::check(), and craftDecrementOrReplaceInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isGroupRecipeStr()

bool isGroupRecipeStr ( const std::string & rec_name)
inline

References str_starts_with().

Referenced by CraftDefinitionCooking::CraftDefinitionCooking(), CraftDefinitionFuel::CraftDefinitionFuel(), hasGroupItem(), CraftDefinitionCooking::initHash(), CraftDefinitionFuel::initHash(), and inputItemMatchesRecipe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ SHAPELESS_GROUPS_MAX

u16 SHAPELESS_GROUPS_MAX = 30000
constexpr