Commit Graph
100 Commits
Author SHA1 Message Date
Peter Bell fa917259a5 Fix doors and trapdoors closing on server restart 2020-08-25 21:38:49 +01:00
Peter Bell 58ab289b56 Update mbedtls to 2.23.0 2020-07-06 20:53:04 +01:00
Peter Bell ad935ef40f Update libevent to 2.1.12-stable 2020-07-06 20:53:04 +01:00
Peter Bell 829f8d46f0 Update fmtlib to 7.0.0 2020-07-06 20:53:04 +01:00
peterbell10 6036971c77 libevent: Enable IOCP backend on windows (#4745) 2020-06-08 21:03:29 +01:00
peterbell10 99d96337da Fire sim: Handle fuel block being destroyed (#4751) 2020-05-31 20:27:08 +01:00
Peter Bell ce1d6a7ebd Protocol: Avoid crashing on invalid sign text 2020-05-29 13:46:11 +01:00
peterbell10 21ef9e3819 Travis: Fix ccache on debug builds (#4741) 2020-05-16 12:57:14 +01:00
Peter Bell 104961b889 sizeof(char) 2020-05-16 09:39:05 +01:00
Peter Bell c1e9d9d0e0 Use thread safe localtime_r on linux 2020-05-16 09:39:05 +01:00
Peter Bell 89c9a7f563 Enable debug logging in test builds 2020-05-16 09:39:05 +01:00
Peter Bell 6dee68cb63 Avoid a copy when logging lua strings 2020-05-16 09:39:05 +01:00
Peter Bell 3189a3cbee Update logging code to reduce unnecessary string copying:
* Write into a single fmt::memory_buffer
* Use string_view instead of AString for listener callbacks
* Also collapsed vFLOG and vLOG functions into one per formatting type
2020-05-16 09:39:05 +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 edb548f9d6 Generate "LuaState_Typedefs.inc" before running clang-tidy 2020-05-13 21:49:38 +01:00
peterbell10 84289a2ba9 Cleanup some workarounds and warnings (#4735)
* Cleanup thread_local usage in FastRandom

* Use constexpr to avoid clang warning

* Fix more Wglobal-constructor warnings

* Make MSVC happy?
2020-05-10 16:16:49 +00:00
peterbell10 154df6b09d Cleanup unneeded globals (#4736) 2020-05-10 16:16:38 +00:00
Peter Bell 1123c95cf2 Enable C++17 in build 2020-05-09 20:37:16 +01:00
peterbell10 e6634ed26c Update submodules (#4727)
Closes #4708

This updates jsoncpp, mbedtls, TCLAP and SQLiteCpp to their latest stable release. A few additional changes were needed:

* jsoncpp deprecated Reader, FastWriter and StyledWriter which I've replaced
  with some helper functions in JsonUtils.cpp

* SQLiteCpp changed how it builds with external sqlite libraries, now expecting
  them to be installed. The simplest path was to remove sqlite from cuberite's
  submodule and just use SQLiteCpp's internal version.
2020-05-09 15:51:15 +01:00
peterbell10 bd54cb71e5 Fix clang-tidy errors (#4730) 2020-05-09 01:38:17 +00:00
Peter Bell a5be5310af Fix clang tidy on circle-ci 2020-05-08 22:57:51 +01:00
peterbell10 c4ca11b372 Fix SetBlockMeta call in observer handler (#4728) 2020-05-08 09:46:03 +01:00
peterbell10 57952505e5 Update fmt to 6.2.0 (#4718)
* Update fmt to 6.2.0
2020-05-05 22:52:14 +01:00
peterbell10 8e2dfce84b Require semi-colon at end of function-like macros (#4719) 2020-05-05 20:39:59 +00:00
peterbell10 c0e7708aa7 Fix incorrect relative coords usage in farmland handler (#4690) 2020-04-24 17:29:12 +00:00
Peter Bell 96bd4637d7 Implement glowing redstone ore 2020-04-16 23:49:33 +01:00
Peter Bell 43525c5df8 Acquire chunk map CS when accessing player entities 2020-04-13 17:13:38 +02:00
peterbell10 19ad96561c Filter blocks to add to redstone sim's wake queue (#4621) 2020-04-05 19:20:52 +00:00
peterbell10 aac592f985 Manage block entity lifetime with unique_ptr (#4080) 2020-04-03 23:23:38 +02:00
peterbell10 59e38d1a46 Fix explosion knockback issues and tweak knockback strength (#4590) 2020-04-02 09:29:42 +02:00
peterbell10 6116f899de Fix client disconnect assert (#4579) 2020-03-29 22:58:19 +02:00
peterbell10 1bc24055d5 cClientHandle: Only allow m_State to increase (#4533)
* cClientHandle: Only allow m_State to increase

* WasAddedToWorld was incorrect if kicked

* Rewrite cClient::Destroy with a guard clause
2020-03-28 10:44:44 +00:00
peterbell10 396bf622ca CI: Install ccache on macos (#4489) 2020-03-27 11:20:30 +01:00
peterbell10 d7a726a423 Update LastSentPosition when entity has no speed (#4487)
* Update LastSentPosition when entity has no speed

* Restructure BroadcastMovementUpdate and always process relmove
2020-03-04 16:47:51 +02:00
Peter Bell fb2ef33c89 Correct block transparencies 2019-12-05 15:26:47 +01:00
peterbell10 7996571a6d CI: Add arm build to travis (#4422)
* Add arm to travis build matrix
* Pin clang-3.5 build to ubuntu trusty
* Add ccache to build
This explicitly excludes macOS since the images don't come with ccache
installed and the install time is not justified by the time saved.
2019-11-10 16:55:24 +00:00
peterbell10 7678d5e6ed Fix race condition in UrlClientTest 2019-09-10 14:18:10 +02:00
peterbell10 a2547bf1fe cBoundingBox: Fix tolua warning (#4361)
tolua was warning about no support for `operator =`.
Ref: #4360
2019-08-08 19:49:00 +01:00
peterbell10 9dc1343bda Ignore whitespace only lines in brewing and furnace recipes (#4332) 2019-06-11 13:39:44 +01:00
peterbell10 7d512f2191 Limit the size of cListAllocationPool's free list 2019-02-20 09:07:44 +00:00
peterbell10 4727ed2084 Add a formatting function for Vector3 (#4282)
* Vector3: Add custom fmt compatible formatter.

* cLuaState: Add fmt version of ApiParamError

* Use vector formatting in manual bindings

* Always log vectors with FLOG
2018-09-24 21:33:39 +01:00
peterbell10 ee84197014 Force all headers other than "Globals.h" to be included with relative paths (#4269)
Closes #4236

CMake now creates a header file in the build directory under the path "include/Globals.h" which just includes "src/Globals.h" with an absolute path. Then instead of adding "src/" to the include directories, it adds "include/".

#include "Globals.h" still works by including the build generated file and any other src-relative path will not work.
2018-08-29 01:51:25 +01:00
peterbell10 2d3ad7f1ae Circle 2.0: Use workspace instead of cache (#4291) 2018-08-25 12:40:10 +01:00
peterbell10 907c22aa12 Move to CircleCI-2.0 (#4225) 2018-08-25 11:25:21 +01:00
peterbell10 be9d7f0d09 Fix use item doc error (#4279)
The documentation now matches what's passed to lua.
Fixes #4194
2018-08-03 09:11:56 +01:00
peterbell10 1e014a54dc Ocelots no longer multiply exponentially (#4272)
Along with a call to `destroyentities`, this fixes #4271

I'm guessing the intention of this code was to modify the normal spawning of ocelots. However, `cEntity::SpawnOn` is actually called to send the entity to an individual client. That means this code was run for every single player, every time they were sent a chunk with ocelots in it. Thus, the ocelots population would grow exponentially as players log in and move around.
2018-07-30 12:49:46 +01:00
peterbell10 cdd8e42587 cWorld: Manually bind deprecated broadcast functions (#4265)
Ref: https://github.com/cuberite/cuberite/pull/4264#discussion_r204769193
2018-07-27 00:12:41 +01: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 c94d7184eb Broadcast refactor (#4264)
* Move Broadcast functions from cChunkMap to cBroadcaster

- Remove cBroadcastInterface in favour of cBroadcaster.

- cChunk: Remove broadcast functions.

* resurect broadcast interface

* Absorb cBroadcaster into cWorld.
Removes the need for forwarding the function calls.

* Improve const-correctness

* Use Int8 instead of char

+ Comment `ForClients` functions

* Improve comments

* Broadcaster: Rename ForClients functions
2018-07-24 22:30:49 +01:00
peterbell10 b5f29d5d2c Stop cFunctionRef constructor from disabling default copy constructor. (#4173)
* Stop cFunctionRef constructor from disabling default copy constructor.
+ cFunctionRef: Improve documentation
2018-07-24 22:30:05 +01:00
peterbell10 31a11a6df4 Optimise chunk set (#4260)
Closes #1244

Initially I was just going to add the cChunkData to cSetChunkData but profiling revealed 
that the copying wasn't even the biggest slowdown. Much more time was being spent in 
cChunk::CreateBlockEntities and cChunk::WakeUpSimulators than was in memcpy so I've made 
those significantly faster as well.

Optimisations performed:
 * cSetChunkData now stores blocks in a cChunkData object
 * cChunkData objects can now perform moves even if they are using different pools
 * cChunk::CreateBlockEntities now iterates in the correct order and only over present chunk sections
 * Similarly for cChunk::WakeUpSimulators
 * cSetChunkData::CalculateHeightMap now shortcuts to the highest present chunk section before checking blocks directly
2018-07-23 19:12:51 +01:00
peterbell10 e27290f7d2 cPawn: Reset last ground height in ResetPosition (#4261)
Prevents fall damage after teleporting/portaling to a lower height.

Fixes #3457
2018-07-23 17:26:48 +01:00
peterbell10 7b431bed51 cIsThread: Reset m_ShouldTerminate after the thread has stopped (#4258)
This allows threads to be restarted after stopping.

Fixes #4257
2018-07-22 22:35:58 +01:00
peterbell10 4fbf04413d Make offline UUIDs consistent with vanilla. (#4178)
Fixes #4177

This is a breaking change to existing Cuberite permissions settings.
2018-07-20 00:30:09 +01:00
peterbell10 211cec621e cBlockArea: Write all present data types by default (#4252)
cBlockArea::Write now defaults to use GetDataTypes() instead of assuming all data types are present.
Fixes cuberite/WorldEdit#130
2018-07-19 22:36:46 +01:00
peterbell10 24603a7640 Flush stdout after resetting console colour. (#4240) 2018-06-20 09:15:57 +02:00
peterbell10 a4dbb5c582 Prefer static_cast to reinterpret_cast (#4223)
* Change reinterpret_cast -> static_cast wherever possible
* Remove more unnecessary `const_cast`s.

reinterpret_casts should be avoided for the same reason as c-style casts - they don't do any type-checking. reinterpret_cast was mainly being used for down-casting in inheritance hierarchies but static_cast works just as well while also making sure that there is actually an inheritance relationship there.
2018-05-02 08:50:36 +01:00
peterbell10 86a8fdf3fe tolua++ bindings use nullptr. (#4219)
Fixes compilation with -Wzero-as-null-pointer-constant.
2018-04-27 23:22:41 +02:00
peterbell10 319b30eec6 Fix fishing timer (#4217)
Fixes ["Fishing Speed Too Slow"](https://forum.cuberite.org/thread-3175-post-29000.html#pid29000).

Interestingly, the constants @NiLSPACE points out are actually correct:
```cpp
(Random.RandInt(100, 900) - static_cast<int>(a_Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchLure) * 100))
```
100 to 900 ticks is the correct timing of 5-45 seconds. However, the timer is only updated when the floater is in the water and the server side position was actually bobbing in and out of the water. This meant the timer took ~2-3x longer than it should.

With this change the floater position is always in the water and so the timer works as expected.
2018-04-27 16:33:45 +01:00
peterbell10 4bf160d596 Update m_LastSentPosition in TeleportToCoords and DoMoveToWorld. (#4211) 2018-04-11 08:39:24 +01:00
peterbell10 1e312296cc Fix cUUID::Variant (#4213) 2018-04-08 00:20:53 +02:00
peterbell10 4f26f653e1 Add cPluginManager::GenericCallHook (#4027)
Replace repetitive CallHook functions with a generic implementation.
Also converts some loops to range-based for.

Related to #1134
2018-03-02 10:40:48 +00:00
peterbell10 999faa9d90 cLightingThread: Faster chunk reading (#4185)
Profiled at a 10x speedup for cLightingThread::ReadChunks.
2018-02-21 10:30:48 +00:00
peterbell10 1ea36298d2 Fix cUrlClient leak (#4125)
Fixes #4040
* The TCP connection is now shutdown after OnBodyFinished
* Any open connections are closed when cNetworkSingleton::Terminate() is called.
* Removed ownership cycles in cUrlClientRequest
* Added a check to the test to ensure there are no leaks.
2018-02-20 17:08:46 +00:00
peterbell10 cf75d7b2c5 cBlockInfo: Deprecate direct access to variables. (#4184) 2018-02-20 10:43:28 +00:00
peterbell10 d3c1c626f5 Deal with covered switches consistently (#4161)
* Fixes a number of "<function>: not all control paths return a value" warnings on MSVC.

* Introduces the UNREACHABLE global macro and uses it instead of conditionally compiled switch defaults.

* Move cNBTParseErrorCategory from FastNBT.h into FastNBT.cpp to prevent bad calls to message()
2018-02-04 23:07:12 +00:00
peterbell10 2df14a0496 cChunk and cChunkData: Use vectors for block get and set functions (#4172)
* cChunkData: Change interface to use Vector3i
* cChunk: Add Vector3i overloads for bounded block get and set functions.
2018-02-04 22:15:31 +00:00
peterbell10 f0c735e846 A player's inventory is always opened by its owner. (#4176)
Fixes #4093

Window updates are only broadcast to players in the m_OpenedBy list. Normally players are added after sending a window open packet but no packet is sent for a player's inventory. This meant broadcasts were never sent for the inventory window.
2018-01-28 17:24:59 +00:00
peterbell10 95108c134d cClientHandle: Always call HOOK_PLAYER_RIGHT_CLICK (#4149)
Reverts the reduction in cases where the hook was called, a change which broke plugins.
2018-01-25 08:10:16 +00:00
peterbell10 7f0500e4c2 Fix android build (#4169) 2018-01-22 21:03:17 +00:00
peterbell10 fa4844e168 CMake: Fix test builds on MSVC (#4131)
* Add test dependency missing for MSVC builds.

* Appveyor builds tests and tools
2018-01-22 09:39:41 +00:00
peterbell10 7f4324f0e0 Update fmt to fix BSD build (#4162) 2018-01-22 09:37:37 +00:00
peterbell10 67f49e1a4a Fix cross compilation (#4163) 2018-01-21 20:18:24 +00:00
peterbell10 ab350d1e43 cItemGrid: Allocate storage lazily (#4083)
* cItemGrid: Allocate storage lazily
* cItemGrid: Fix spelling, Prioritary -> Priority
2018-01-21 18:45:13 +00:00
peterbell10 cd88a11735 Update libevent to 2.1.8 (#4152) 2018-01-21 10:03:39 +00:00
peterbell10 e88b3fa2fe New movement system for leashed entities (#4147)
* New movement system for leashed entities
Entities are accelerated towards the leashed to entity as if by a spring.
 * Mobs now pathfind close to but not directly to the leashing entity.
* Also minor comment changes
2018-01-17 21:40:58 +00:00
peterbell10 a72891fbb0 cWindow: Fix slot area priority when double click stacking. (#4086)
Fixes #4084
2018-01-15 11:35:27 +00:00
peterbell10 44519225b2 Travis: Remove gdb (#4140) 2018-01-14 15:08:08 +00:00
peterbell10 6e522d05da readme: Be explicit that Cuberite works with Java Edition Clients. (#4138) 2018-01-08 06:43:08 +00: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
peterbell10 177273006e cLuaState: Update Push for entities. (#4128)
Fixes #4127

Some classes were exported but were only pushed as a cEntity
meaning exported functions were inaccessible.
This brings cLuaState::Push(cEntity *) up to date with all exported entities.
2018-01-03 11:38:00 +00:00
peterbell10 533c95d9e2 Protocol: Fix potion metadata parsing (#4116) 2017-12-26 18:51:38 +00:00
peterbell10 832b394715 Fix Travis build (#4101)
Stop using gdb on osx - was breaking the build
Add clang 3.5 build as travis now defaults to 5.0
Fix unknown-warning-option errors on AppleClang
ProtoProxy: Use nullptr
UrlClientTest: add override to callback destructor
Update jsoncpp to use nullptr
2017-12-22 18:25:46 +00:00
peterbell10 e0ff5f5639 cInventory: Add listener to shield slot. (#4095) 2017-12-21 11:55:23 +00:00
peterbell10 ef091fe24b cBlockRail: Fix assertion failure (#4075) 2017-11-21 21:54:21 +00:00
peterbell10 bf5e6874fe cItemHandler: Update max stack size of old doors. (#4072) 2017-11-20 11:04:17 +00:00
peterbell10 c54bf40ef9 cWorld Threads: Seperate initialization and thread start.
Prevents nullptr dereferences before Start has been called.
2017-10-21 19:33:22 +02:00
peterbell10 1537ebed6f cWorld: Move Initialization from Start to the constructor.
Start now does nothing more than launch the world's threads.
2017-10-21 19:33:22 +02:00
peterbell10 5b6b043752 Fix tool builds on AppleClang 2017-10-21 19:31:45 +02:00
peterbell10 4dce6a59aa TravisCI: Add osx builds 2017-10-21 19:31:45 +02:00
peterbell10 0bacda3269 Implement horse inventory (#4053)
* Implement horse inventory

* Fix sign conversions

* Add API doc for ItemCategory::IsHorseArmor

* Improve HandleOpenHorseInventory comment and style fixes.
2017-10-21 17:56:09 +01:00
peterbell10 744cdb726d Fix minecart deceleration (#4059) 2017-10-21 17:53:24 +01:00
peterbell10 8866a28cf8 Fix explosion interaction with block entities. (#4052)
* WriteBlockArea: Fix erasing of block entities.

* cChunkMap::DoExplosionAt destroys block entities
2017-09-27 22:22:15 +01:00
peterbell10 4b14a5b4c1 cPressurePlateHandler: Fix uninitialised variables. (#4047) 2017-09-25 21:41:11 +01:00
peterbell10 463fa48aec cBlockArea: Fix performance regression (#4045) 2017-09-23 17:47:46 +01:00
peterbell10 e883aa828c Add support for release 1.12.2 (#4041) 2017-09-21 14:12:43 +01:00
peterbell10 15fd4ef829 Only allow snow to be placed where valid. Fixes #2920. 2017-09-21 13:01:00 +01:00
peterbell10 ab4f0df5b9 Only allow rails to be placed where valid.
Fixes #3507.
2017-09-21 13:01:00 +01:00
peterbell10 8835bf344d cRoot: Make PollPeriod representation 32 bit (#4030) 2017-09-19 14:14:44 +01:00
peterbell10 b5fa96f4f8 cFinishGenPreSimulator: Preserve sand meta (#4025)
Fixes #1516.
2017-09-18 08:45:32 +01:00