summaryrefslogtreecommitdiffstats
path: root/src/CraftingRecipes.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2021-01-26Fix debug macro situation (#5114)Tiger Wang1-3/+1
Use the standard NDEBUG.
2020-08-01Replaced cpp14::make_unique<> with std::make_unique<>.Mattes D1-2/+2
2020-07-14Introduce recipe book functionality (#4493)Tobias Wilken1-5/+90
* Introduce recipe book functionality The recipe book helps especially new players. Missing it gives the impression that cuberite is not as advanced as it is. The handling of the recipe book uses the following functions: - Unlock Recipes (https://wiki.vg/index.php?title=Protocol&oldid=14204#Unlock_Recipes) to make recipes available and show the notification for new recipes. Initialization is done on player login for known ones, the update is done when new items are discovered. - Craft Recipe Request (https://wiki.vg/index.php?title=Protocol&oldid=14204#Craft_Recipe_Request) when the user selects a recipe from the recipe book to fill the slots. Known recipes are initialized on player login via `Unlock Recipes` with `Action` 0. As soon as a new recipe is discovered this is added via `Unlock Recipes` with `Action` 1. To be able to know and recognize new recipes the player class is extended with `KnownItems` and `KnownRecipes`. As soon as a player touches an item this is compared to the list of `KnownItems`, if the item is unknown the recipes are checked for this item and the other ingredients are checked with the list of `KnownItems`. If a full match is discovered the recipe is unlocked with the client and stored in the `KnownRecipes`. To unlock recipes the recipe ID is sent to the client. A mapping file (for protocol 1.12.2) translated the minecraft recipe names to ids. The crafting.txt is extended with and minecraft recipe names is possible. Limitations: Only a single recipe is added to the crafting area. Multiple clicks or shift click does not increase the number of builds. Co-authored-by: peterbell10 <peterbell10@live.co.uk> * Address first issues mentioned by @peterbell10 - Some linting - Extract loading of recipe specific protocol mapping into a function - Build `RecipeNameMap` only once - Use `std::optional` - Extract `LoadRecipe` from `Window` * Start to implement new suggestions * Update with suggestions from @peterbell10 * Some minor cleanup * Update protocol packet IDs * Remove unused include * Include header in cmake * Change a vector to integer counter * Change dromedaryCase method names to PascalCase * Address suggestions from @madmaxoft * Read Protocol subdirectories to load recipe books To load all recipebooks iterate over the `Protocol` subdirectories to find mapping files. Co-authored-by: peterbell10 <peterbell10@live.co.uk>
2020-05-15Enable some more clang-tidy linter checks (#4738)peterbell101-3/+3
* Avoid inefficient AString -> c_str() -> AString round trip * Avoid redundant string init expressions * Avoid unnecessary return, continue, etc. * Add .clang-format to help with clang-tidy fix-its * Avoid unnecessary passing by value * Avoid unnecessary local copying * Avoid copying in range-for loops * Avoid over-complicated boolean expressions * Some violations missed by my local clang-tidy * Allow unnecessary continue statements * Add brackets * Another expression missed locally * Move BindingsProcessor call into clang-tidy.sh and add space * Fix pushd not found error * Different grouping of CheckBlockInteractionRate
2020-05-09Enable C++17 in buildPeter Bell1-7/+3
2020-04-03Pulled the BlockID and BlockInfo headers from Globals.h. (#4591)Mattes D1-2/+2
The BlockID.h file was removed from Globals.h and renamed to BlockType.h (main change) The BlockInfo.h file was removed from Globals.h (main change) The ENUM_BLOCK_ID and ENUM_ITEM_ID enum names were replaced with ENUM_BLOCK_TYPE and ENUM_ITEM_TYPE (cosmetics) The various enums, such as eDimension, eDamageType and eExplosionSource were moved from BlockType.h to Defines.h, together with the helper functions for converting between them and strings (StringToDimension et al.) (minor) Many inline functions were moved from headers to their respective cpp files, so that BlockType.h could be included only into the cpp file, rather than the header. That broke our tests a bit, since they pick bits and pieces out of the main code and provide stubs for the rest; they had to be re-stubbed and re-verified. eMonsterType values are no longer tied to E_ITEM_SPAWN_EGG_META_* values
2020-03-23Don't attempt to give bucket with item count of 0Mat1-1/+1
2018-07-26CheckBasicStyle: Check number of empty lines between functions (#4267)peterbell101-0/+1
Add check for number of empty lines between functions and fix the corresponding failures
2018-01-03Add the fmt library (#4065)peterbell101-2/+2
* Replaces AppendVPrintf with fmt::sprintf * fmt::ArgList now used as a type safe alternative to varargs. * Removed SIZE_T_FMT compatibility macros. fmt::sprintf is fully portable and supports %zu. * Adds FLOG functions to log with fmt's native formatting style.
2016-02-05Bulk clearing of whitespaceLogicParrot1-28/+28
2015-07-15Leather Armor can now be dyed.Samuel Barney1-0/+192
* Created new color class to handle dye-related coloring
2015-07-12Changing the shared_ptr/unique_ptr constructors to the make_shared/make_unique functionsbibo381-2/+2
2015-06-07Fixed styleNounours Heureux1-1/+1
2015-06-07Cake crafting now give back the bucketNounours Heureux1-1/+8
2015-05-31Fixed crafting recipe matching.Mattes D1-0/+3
Fixes #2096.
2015-05-24Made -Weverything an error.tycho1-2/+2
2015-04-16Recipes match zero DamageValue strictly.Mattes D1-2/+2
To match any DamageValue for the ingredient, an explicit "-1" as the DamageValue must be specified. Fixes #1859.
2015-04-16Fixed PolishedGranite et al crafting recipes.Mattes D1-0/+1
Fixes #1774. Ref.: #1859
2014-12-04Fixed the CRAFTING_NO_RECIPE hook call.Mattes D1-1/+1
It used a pointer-to-pointer-to-cCraftingRecipe, which the Lua bindings didn't know how to handle, and emitted a warning message at runtime. Fixes #1641.
2014-11-27Replaced auto_ptr with unique_ptr.Mattes D1-3/+3
2014-10-23En masse NULL -> nullptr replaceTiger Wang1-9/+9
2014-10-20En masse NULL -> nullptr replaceTiger Wang1-9/+9
2014-10-15Functions in cPluginManager get references instead of pointers.Mattes D1-4/+4
2014-08-29A better hotfix for CraftingRecipiesTiger Wang1-1/+1
2014-08-29Hotfixed recipe.txt loading.Hownaer1-2/+5
2014-08-13Fixed Integer pasing warnings in CraftingRecipies.cppTycho1-4/+2
2014-08-13Fixed type issues in CraftingRecipe.cppTycho1-2/+2
2014-08-13Fixed forgotten error checkingTycho1-1/+5
2014-07-21Style: Normalized to no spaces before closing parenthesis.madmaxoft1-1/+1
2014-07-21Style: Normalized spaces after if, for and while.madmaxoft1-1/+1
2014-07-17Normalized comments.madmaxoft1-3/+3
This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign.
2014-07-17Fixed spaces around single-line comments.madmaxoft1-1/+1
There should be at least two spaces in front and one space after //-style comments.
2014-07-17Fixed basic whitespace problems.madmaxoft1-4/+4
Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines.
2014-06-19Nullify deleted pointers.archshift1-0/+1
2014-04-23Small changesTiger Wang1-2/+2
2014-04-21Fixed a warning in CraftingRecipes.Mattes D1-1/+1
2014-04-18Did some static analysis, fixed some bugs and optimized a lot of codejfhumann1-4/+6
2014-03-12Added additional macros to support the MSVC size_t format and changed all formats to use the macrosTycho1-1/+1
2014-03-11Fixed a load of format string errorsTycho1-1/+1
2014-03-10Fixed test assertsTycho1-0/+2
2014-03-09Moved firework handler to separate functionTiger Wang1-48/+45
* Also simplified and improved readability of code
2014-03-09Fix Linux compileTiger Wang1-2/+3
2014-02-27Implemented ballistic missiles (fireworks)Tiger Wang1-1/+88
+ Added fireworks
2013-12-08Moved bindings-related to a Bindings subfolder.madmaxoft1-1/+1
Ref.: #407
2013-11-24Moved source to srcAlexander Harkness1-0/+0
2013-09-28Minor startup streamliningTiger Wang1-2/+2
* LOGD'd unneeded debugging messages, streamlining startup + Added a basic timer for how long in seconds it took to start up + Added two checks for plural (plugin/s, second/s)
2013-05-07Replaced MIN / MAX with std::min and std::maxmadmaxoft@gmail.com1-4/+4
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1455 0a769ca7-a7f5-676a-18bf-c427514a06d6
2013-01-12Merged branch "branches/hooks" into "trunk".madmaxoft@gmail.com1-13/+13
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1139 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-11-18CraftingRecipes parse now dumps lines it cannot parse.madmaxoft@gmail.com1-0/+5
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1052 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-09-24Source files cleanup: The rest of the files renamed.madmaxoft@gmail.com1-2/+2
git-svn-id: http://mc-server.googlecode.com/svn/trunk@887 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-09-20Refactored windows.madmaxoft@gmail.com1-1/+1
As described on the forum: http://forum.mc-server.org/showthread.php?tid=561 For now, only basic clicking works; shift-click not implemented yet. git-svn-id: http://mc-server.googlecode.com/svn/trunk@867 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-06-14Attempt to bring sanity to newlines across systems.cedeel@gmail.com1-765/+765
git-svn-id: http://mc-server.googlecode.com/svn/trunk@606 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-06-12Added working crafting hooks HOOK_PRE_CRAFTING, HOOK_CRAFTING_NO_RECIPE and HOOK_POST_CRAFTINGmadmaxoft@gmail.com1-6/+17
git-svn-id: http://mc-server.googlecode.com/svn/trunk@598 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-06-12Updated the crafting recipes architecture to better support crafting hooks. Removed the old recipe file and implementation altogether.madmaxoft@gmail.com1-22/+249
git-svn-id: http://mc-server.googlecode.com/svn/trunk@597 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-06-09Fixed a bug in crafting recipes - would consume multiple items of asterisked ingredients (FS #205)madmaxoft@gmail.com1-18/+25
git-svn-id: http://mc-server.googlecode.com/svn/trunk@593 0a769ca7-a7f5-676a-18bf-c427514a06d6
2012-06-04Added the new recipe parser, parsing the crafting.txt file. Included are a few recipes. The old parser still works, but will be replaced soon.madmaxoft@gmail.com1-0/+520
git-svn-id: http://mc-server.googlecode.com/svn/trunk@549 0a769ca7-a7f5-676a-18bf-c427514a06d6