MCPcopy Create free account
hub / github.com/TurningWheel/Barony / buildRecipeList

Function buildRecipeList

src/interface/interface.cpp:20353–20652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20351}
20352
20353void buildRecipeList(const int player)
20354{
20355 auto& alchemy = GenericGUI[player].alchemyGUI;
20356 auto& recipes = alchemy.recipes;
20357
20358 int entryx = 0;
20359 int entryy = 0;
20360
20361 auto oldSize = recipes.recipeList.size();
20362 recipes.recipeList.clear();
20363
20364 std::unordered_map<int, std::pair<std::vector<Item*>, int>> inventoryPotions;
20365 bool hasEmptyBottle = false;
20366 alchemy.torchCount.count = 0;
20367 for ( node_t* node = stats[player]->inventory.first; node; node = node->next )
20368 {
20369 Item* item = (Item*)node->element;
20370 if ( !item ) { continue; }
20371 if ( item->type == TOOL_TORCH )
20372 {
20373 alchemy.torchCount.count += item->count;
20374 }
20375 if ( itemCategory(item) == POTION )
20376 {
20377 if ( item->type == POTION_EMPTY )
20378 {
20379 hasEmptyBottle = true;
20380 }
20381 if ( !item->identified )
20382 {
20383 continue;
20384 }
20385 if ( inventoryPotions.find(item->type) == inventoryPotions.end() )
20386 {
20387 inventoryPotions[item->type].second = 0;
20388 }
20389 if ( !itemIsEquipped(item, player) )
20390 {
20391 inventoryPotions[item->type].first.push_back(item);
20392 }
20393 inventoryPotions[item->type].second += item->count;
20394 }
20395 }
20396
20397 if ( alchemy.currentView == alchemy.ALCHEMY_VIEW_COOK || alchemy.currentView == alchemy.ALCHEMY_VIEW_RECIPES_COOK )
20398 {
20399 if ( GenericGUI[player].alembicEntityUid != 0 && !GenericGUI[player].alembicItem && uidToEntity(GenericGUI[player].alembicEntityUid) )
20400 {
20401 alchemy.torchCount.count = -1;
20402 }
20403 else if ( players[player] && players[player]->entity )
20404 {
20405 auto entLists = TileEntityList.getEntitiesWithinRadiusAroundEntity(players[player]->entity, 2);
20406 for ( std::vector<list_t*>::iterator it = entLists.begin(); it != entLists.end(); ++it )
20407 {
20408 list_t* currentList = *it;
20409 node_t* node;
20410 for ( node = currentList->first; node != nullptr; node = node->next )

Callers 2

updateAlchemyMenuMethod · 0.85
updateRecipePanelMethod · 0.85

Calls 12

itemIsEquippedFunction · 0.85
entityDistFunction · 0.85
hideRecipeFromListFunction · 0.85
RecipeEntry_tClass · 0.85
copyItemFunction · 0.85
itemCategoryFunction · 0.50
uidToEntityFunction · 0.50
sizeMethod · 0.45
clearMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected