1
0
Fork 0
Commit Graph

46 Commits

Author SHA1 Message Date
Tiger Wang 50a94f972d
Fix debug macro situation (#5114)
Use the standard NDEBUG.
2021-01-26 09:41:55 +00:00
Mattes D 46398f4671 Replaced cpp14::make_unique<> with std::make_unique<>. 2020-08-01 20:04:31 +01:00
Tobias Wilken 36eab1b323
Introduce recipe book functionality (#4493)
* 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-07-14 17:56:42 +01:00
peterbell10 13144a08e4
Enable some more clang-tidy linter checks (#4738)
* 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-14 22:15:35 +00:00
Peter Bell 1123c95cf2 Enable C++17 in build 2020-05-09 20:37:16 +01:00
Mattes D 01b8ed5295
Pulled the BlockID and BlockInfo headers from Globals.h. (#4591)
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-04-03 08:57:01 +02:00
Mat 7d05e4402f
Don't attempt to give bucket with item count of 0 2020-03-23 11:39:32 +02:00
peterbell10 950aeffff8
CheckBasicStyle: Check number of empty lines between functions (#4267)
Add check for number of empty lines between functions and fix the corresponding failures
2018-07-26 22:24:36 +01:00
peterbell10 757231cc6e
Add the fmt library (#4065)
* 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.
2018-01-03 17:41:16 +00:00
LogicParrot ca6ef58b1e Bulk clearing of whitespace 2016-02-05 23:50:18 +02:00
Samuel Barney 561296f269 Leather Armor can now be dyed.
* Created new color class to handle dye-related coloring
2015-07-15 14:05:36 -06:00
bibo38 0cb0bbe51a Changing the shared_ptr/unique_ptr constructors to the make_shared/make_unique functions 2015-07-12 21:02:47 +02:00
Nounours Heureux 24210cbd6f Fixed style 2015-06-07 15:22:47 +02:00
Nounours Heureux 1a7e8f3e4f Cake crafting now give back the bucket 2015-06-07 15:03:47 +02:00
Mattes D 25e83bc1d9 Fixed crafting recipe matching.
Fixes #2096.
2015-05-31 21:21:57 +02:00
tycho dae9e5792a Made -Weverything an error. 2015-05-24 12:56:56 +01:00
Mattes D 0b3fd73f90 Recipes match zero DamageValue strictly.
To match any DamageValue for the ingredient, an explicit "-1" as the DamageValue must be specified.
Fixes #1859.
2015-04-16 21:33:42 +02:00
Mattes D ffe7dae4fc Fixed PolishedGranite et al crafting recipes.
Fixes #1774. Ref.: #1859
2015-04-16 20:59:57 +02:00
Mattes D 34807248e2 Fixed the CRAFTING_NO_RECIPE hook call.
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-12-04 09:21:57 +01:00
Mattes D 186b2f3bd0 Replaced auto_ptr with unique_ptr. 2014-11-27 21:27:03 +01:00
Tiger Wang a26541a7c3 En masse NULL -> nullptr replace 2014-10-22 20:12:49 -07:00
Mattes D eeb580a74e Functions in cPluginManager get references instead of pointers. 2014-10-15 19:09:09 +02:00
Tiger Wang 389614c959 A better hotfix for CraftingRecipies 2014-08-29 15:12:45 +01:00
Hownaer c4d7f7996b Hotfixed recipe.txt loading. 2014-08-29 00:42:33 +02:00
Tycho 781e1e6264 Fixed Integer pasing warnings in CraftingRecipies.cpp 2014-08-13 13:03:56 +01:00
Tycho c3c3d3a72d Fixed type issues in CraftingRecipe.cpp 2014-08-13 12:14:55 +01:00
Tycho 8f7b9acb48 Fixed forgotten error checking 2014-08-13 12:10:21 +01:00
madmaxoft 93d29555e5 Style: Normalized to no spaces before closing parenthesis. 2014-07-21 17:40:43 +02:00
madmaxoft 6be79575fd Style: Normalized spaces after if, for and while. 2014-07-21 17:38:50 +02:00
madmaxoft 2423fbf2ef Normalized comments.
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-17 22:15:34 +02:00
madmaxoft 7fff12bfac Fixed spaces around single-line comments.
There should be at least two spaces in front and one space after //-style comments.
2014-07-17 19:13:23 +02:00
madmaxoft 993fd14ddf Fixed basic whitespace problems.
Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines.
2014-07-17 16:33:09 +02:00
archshift e8143de01b Nullify deleted pointers. 2014-06-19 01:49:56 -07:00
Tiger Wang 48904ae201 Merge branch 'master' into fixes
Conflicts:
	src/World.h
2014-04-24 18:57:25 +01:00
Tiger Wang f763242e5c Small changes 2014-04-23 21:06:07 +01:00
Mattes D 6492aa000b Merge pull request #909 from jfhumann/fixes
Bug fixes and optimizations.

We need to visit the API functions and check that they return only those values expected. `cWorld::CreateProjectile()` seems affected, too, by the same issue of ToLua returning extra values. In the cleanest form, these functions will need moving to ManualBindings.cpp
2014-04-22 13:34:32 +02:00
Mattes D 4c7621ed16 Fixed a warning in CraftingRecipes. 2014-04-21 09:21:31 +02:00
jfhumann 013da806ec Did some static analysis, fixed some bugs and optimized a lot of code 2014-04-18 21:09:44 +02:00
Tycho 862e219443 Added additional macros to support the MSVC size_t format and changed all formats to use the macros 2014-03-12 10:34:50 -07:00
Tycho 16b27c4b7a Fixed a load of format string errors 2014-03-11 14:16:08 -07:00
Tycho e9e2852ce1 Fixed test asserts 2014-03-10 13:12:43 -07:00
Tiger Wang 217aaca699 Moved firework handler to separate function
* Also simplified and improved readability of code
2014-03-09 12:48:53 +00:00
Tiger Wang e2cbebe522 Fix Linux compile 2014-03-09 12:48:49 +00:00
Tiger Wang baf2d88921 Implemented ballistic missiles (fireworks)
+ Added fireworks
2014-02-26 23:33:52 +00:00
madmaxoft 044fd237b6 Moved bindings-related to a Bindings subfolder.
Ref.: #407
2013-12-08 12:17:54 +01:00
Alexander Harkness 675b4aa878 Moved source to src 2013-11-24 14:19:41 +00:00