Commit Graph
100 Commits
Author SHA1 Message Date
Tiger Wang ce6f8b3557 Fix finisher generating invalid pumpkin
Result was black spot in the ground because the meta exceeded 3 and the client didn't render anything.

Been here since the beginning? http://github.com/cuberite/cuberite/blob/fbabf9ee8c7f0940e6f7d01e0362849bf4f6396b/source/FinishGen.cpp#L159
2021-04-01 00:02:44 +01:00
Tiger Wang 8a30a4a7b8 Player data loading cleanup
* Kick player if data were corrupt to avoid making it worse
2021-03-29 23:36:15 +01:00
Tiger Wang 222d9957a1 cIsThread cleanup
+ Semi-gracefully handle unexpected exceptions
* No-one cared about the return values, remove them
2021-03-29 23:36:15 +01:00
Tiger Wang 8ec5552998 Do an early check for empty network buffers (#5172)
Avoid overhead when nothing to do.
2021-03-29 23:36:00 +01:00
Tiger Wang abcc14076c Call ProcessProtocolOut at opportune times 2021-03-28 21:20:13 +01:00
Tiger Wang c24e968f2c Send keep alives slightly less frequently
Ref: http://github.com/cuberite/cuberite/issues/4082#issuecomment-348675321
2021-03-28 15:36:10 +01:00
Tiger Wang 5d11816015 Move some redstone implementations into the source file 2021-03-28 15:36:10 +01:00
Tiger Wang 2687f2df30 Fix chunk block changes being sent out of order (#5169)
* Flush out all pending, buffered changes at the end of each tick, after every chunk is ticked. This makes every block update client-side in unison, instead of unlucky ones only being sent 1 tick later.
* Re-add buffer for outgoing network data; IOCP async WSASend has higher overhead than expected... Fixes regression introduced in 054a89dd9
2021-03-28 14:44:20 +01:00
Tiger Wang 125df19477 Do not fake a tool when converting to pickups (#5170)
* When the cause of destruction was world-induced (CanBeAt check failed) there is no tool. Pass the nullptr directly to ConvertToPickups and let it handle it.
* Fixes #4795
- Remove unused a_Digger parameter to ConvertToPickups.
2021-03-28 14:41:34 +01:00
Tiger Wang 748b121703 Unify DoWithBlockEntity (#5168)
+ DoWith calls now broadcast the block entity and mark the chunk dirty
+ Add block entity change queue to synchronise BE updates with block updates
* Fixed a few incorrect assertions about BE type
- Remove manual overloads
2021-03-28 14:40:57 +01:00
Tiger Wang 5123850db0 Fix Windows XP to 7 compatibility (#5167)
* Partially reverts 01a4e696b
* Unify thread names
- Remove use of GetThreadId API
2021-03-28 13:34:57 +01:00
Tiger Wang 90369deb5a Change TimeOfDay to WorldDate (#5160)
* Change TimeOfDay to WorldDate

* Do not wrap at 20 minutes, continue incrementing
* Fixes #4737
* Fixes #5159
2021-03-20 20:58:19 +00:00
Tiger Wang 55ba39ca0e Don't send ping updates one packet at a time
* Use the batch update feature of the packet.
* Lengthen interval between time and ping update packets (ref. http://github.com/cuberite/cuberite/issues/4082#issuecomment-348675321).
2021-03-19 11:23:30 +00:00
Tiger Wang e3fe9e5e93 Deduplicate WriteBlockEntity 2021-03-17 23:44:59 +00:00
Tiger Wang edf9e39ed7 Mob heads, banners cannot be used
* Fixed UsedBy returning true, blocking block placement
2021-03-17 23:44:59 +00:00
Tiger Wang 5ca3a7c2e7 shared_ptr -> unique_ptr in generators 2021-03-17 23:44:42 +00:00
Tiger Wang 3e3c30496d Add heraldry names to banner pattern API docs 2021-03-15 11:07:54 +00:00
Tiger Wang ca5608c66c Derive HugeMushroom from the base handler
ConvertToPickups is already overridden.
2021-03-15 02:44:39 +00:00
Tiger Wang 61cc1c0190 Change Cobblestone block handler to default
Cobblestone shouldn't be handled with the Stone handler.
2021-03-15 02:44:39 +00:00
Tiger Wang de76503d5c Remove DoesDropOnUnsuitable
This is only overridden false in Vines and Snow. It is called when a CanBeAt check fails, to determine whether DropBlockAsPickups is called. However, Vines and Snow already drop nothing without the right tool, so this function is superfluous.
2021-03-15 02:44:39 +00:00
Tiger Wang 45591cbe7b Properly deprecate more XYZ parameter'd functions (#5147)
* Fixes #5144
2021-03-15 02:28:18 +00:00
Tiger Wang 01a4e696b3 Do protocol decryption in-place (with CryptoAPI on Windows) (#5145) 2021-03-08 16:37:36 +00:00
Tiger Wang d9a2b8611c Mitigate MSVC crash (#5146)
Reference: http://ci.appveyor.com/project/Cuberite/cuberite/builds/38087390/job/p857ibg3x87naw36/messages
2021-03-06 12:59:39 +00:00
Tiger Wang 00e6239b20 Update Core 2021-03-06 01:30:55 +00:00
Tiger Wangand12xx12 868cd94ee9 Prepare ChunkData for BlockState storage (#5105)
* Rename ChunkData Creatable test

* Add missing Y-check in RedstoneWireHandler

* Remove ChunkDef.h dependency in Scoreboard

* Prepare ChunkData for BlockState storage

+ Split chunk block, meta, block & sky light storage
+ Load the height map from disk
- Reduce duplicated code in ChunkData
- Remove saving MCSBiomes, there aren't any
- Remove the allocation pool, ref #4315, #3864

* fixed build

* fixed test

* fixed the debug compile

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
2021-03-05 14:03:55 +01:00
Tiger Wang 81e299f00c Mark UNREACHABLE with intrinsics 2021-02-20 17:46:02 +00:00
Tiger Wang 6aa1d13508 Clang 7? 2021-02-11 01:24:50 +00:00
Tiger Wang 2f1359a0f9 Fix march=native not being enabled
* LINUX doesn't exist apparently, use UNIX instead
+ Add some platform-specific logic to determine whether to use mcpu or march
- Remove duplicated compile option comments
+ Add STATUS level to messages
2021-02-11 01:24:50 +00:00
Tiger Wang 2a6d4ffcd8 Turn off SQLITE_ENABLE_JSON1 2021-02-11 01:24:50 +00:00
Tiger Wang 23745525e0 Update libevent, mbedtls 2021-02-10 10:30:32 +00:00
Tiger Wang 86cfb38211 MSVC warnings 2021-02-10 10:30:32 +00:00
Tiger Wang 7ad054b087 Explodinator performance optimisations
Thanks @lixfel (#4246)
2021-02-07 22:36:15 +00:00
Tiger Wang 5a8e75e6aa Explodinator: fix divide by zero 2021-02-07 22:36:15 +00:00
Tiger Wang be2bf999c2 Fix #5118 2021-02-07 22:36:15 +00:00
Tiger Wang 50a94f972d Fix debug macro situation (#5114)
Use the standard NDEBUG.
2021-01-26 09:41:55 +00:00
Tiger Wang 19302eeb87 Redstone: inline -> static 2021-01-22 22:04:47 +00:00
Tiger Wang 49ef21d650 MultiVersionProtocol: fix two crashes
First one: add missing exception handler in ProcessProtocolIn

Second: remove faulty logic dealing with incomplete packets.

`a_Data = a_Data.substr(m_Buffer.GetUsedSpace() - m_Buffer.GetReadableSpace());`

was incorrect; it attempted to apply a length derived from m_Buffer to an unrelated a_Data. Its purpose was to give cProtocol the data the client sent, minus initial handshake bytes. However, we can use the knowledge that during initial handshake, there is no encryption and every byte can be written unchanged into m_Buffer, to just call cProtocol with a data length of zero. This will cause it to parse from m_Buffer - wherein we have already written everything the client sent - with no a_Data manipulation needed.

Additionally, removed UnsupportedButPingableProtocolException (use of exception as control flow) and encode this state as m_Protocol == nullptr, id est "no protocol for this unsupported version", which is then handled by cMultiVersionProtocol itself.
2021-01-19 09:54:58 +00:00
Tiger Wang 813176fbd1 cChunk: don't inherit from cChunkDef (#5106) 2021-01-18 16:09:10 +00:00
Tiger Wang 054a89dd9e Clarify cClientHandle, cPlayer ownership semantics
+ A cPlayer, once created, has a strong pointer to the cClientHandle. The player ticks the clienthandle. If he finds the handle destroyed, he destroys himself in turn. Nothing else can kill the player.
* The client handle has a pointer to the player. Once a player is created, the client handle never outlasts the player, nor does it manage the player's lifetime. The pointer is always safe to use after FinishAuthenticate, which is also the point where cProtocol is put into the Game state that allows player manipulation.
+ Entities are once again never lost by constructing a chunk when they try to move into one that doesn't exist.
* Fixed a forgotten Super invocation in cPlayer::OnRemoveFromWorld.
* Fix SaveToDisk usage in destructor by only saving things cPlayer owns, instead of accessing cWorld.
2021-01-12 12:34:34 +00:00
Tiger Wang 9328afe65c Convert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses
* Hopefully fixes #5094
2021-01-11 16:39:56 +00:00
Tiger Wang eeb63b8901 zlib -> libdeflate (#5085)
+ Use libdeflate
+ Use std::byte
* Fix passing temporary to string_view
+ Emulate make_unique_for_overwrite
2021-01-11 16:39:43 +00:00
Tiger Wang 16aeb84cd3 Fix potential destruction crashes (#5095)
* Fix potential destruction crashes

* Fix destructors accessing destroyted objects
* Fix cPlayer not destroying windows (Destroyed never called)
* Tentatively fixes #4608, fixes #3236, fixes #3262
- Remove cEntity::Destroyed() and replace with cEntity::OnRemoveFromWorld()

* Add missing call to OnRemoveFromWorld
2021-01-02 13:50:34 +00:00
Tiger Wang 959b263093 Fix AppVeyor IA32 builds (#5096)
* Fix AppVeyor IA32 builds

> The default target platform name (architecture) is that of the host and is provided in the CMAKE_VS_PLATFORM_NAME_DEFAULT variable.

AppVeyor uses AMD64. Oops.

* del cmakecache

* -

* +
2020-12-31 19:43:02 +00:00
Tiger Wang 90ce4ed2b8 Command Blocks: fix a crash
* Don't store a temporary
2020-12-30 12:15:19 +00:00
Tiger Wang abc96bb4ce Avoid an std::list in StreamNextChunk 2020-12-26 17:55:45 +00:00
Tiger Wang bb37e5c152 Streamline ClientHandle chunk send a little
- Removed RemoveFromAllChunks. On destruction cWorld::RemovePlayer calls RemoveClientFromChunks already, and there's no need to manually clear the chunk lists.
2020-12-26 17:55:45 +00:00
Tiger Wang c91335bfbb Don't prematurely exit "downloading terrain" screen on join
- Remove leftover SendPlayerMoveLook from #1500
2020-12-26 17:55:45 +00:00
Tiger Wang 60bc040a9c Make SetAllData's MarkDirty() the chunk's responsibility 2020-12-26 17:55:45 +00:00
Tiger Wang 9fcd2d4210 Avoid a gratuitous dirty when loading chunks with entities
Loaded entities are directly moved into the chunk data, instead of having to go through cWorld, as if they were just spawned. This avoid dirtying the chunk.
2020-12-26 17:55:45 +00:00
Tiger Wang 7f894b2f73 Silverfish: correct search cube 2020-12-26 16:58:53 +00:00
Tiger Wang 14ada52f3a Daylight Sensor: remove redundant delay
Daylight Sensors are already always ticked.
2020-12-26 16:58:53 +00:00
Tiger Wang d9a7c51d4d ViewDistance: unsigned -> signed 2020-12-26 16:58:53 +00:00
Tiger Wang 53ae358d8c Replace custom ChunkCoordinate with cChunkCoords 2020-12-21 23:21:01 +00:00
Tiger Wang f3ec768dfb unique_ptr<cChunkMap> to plain member 2020-12-21 23:21:01 +00:00
Tiger Wang 9518a27357 Prepare for 1.15+ (#4856)
+ Add type-safe container for states
* Split registry Blocks into BlockTypes, BlockStates so the block types enumeration can be #included without too much penalty
* Ensure Registry uses type-safe container
2020-12-21 13:54:04 +00:00
Tiger Wang 5b6bed6b00 Improve Enderman targeting
* Fix look angle checks
* Do LOS trace from eye-height
2020-12-21 13:52:23 +00:00
Tiger Wang 47c0b48bfd Monsters: improve targeting
* Replace DoWithNearestPlayer with bounding box search (avoid iterating through all players in world).
* Do line-of-sight checks from eye-to-eye.
+ Added LOS and LOS lost timer to target lost checks, in addition to distance.
2020-12-21 13:52:23 +00:00
Tiger Wang 491238f799 Chunk: use FAST_FLOOR_DIV 2020-12-21 13:52:15 +00:00
Tiger Wang e7331fe820 Improve Silverfish search
* Start from the inside out, don't always look at the entire search space by bailing out randomly
2020-12-21 13:52:06 +00:00
Tiger Wang d9cd2f741d Comment and code style fix
+ Add static keyword
- Don't capture everything in lambda
2020-12-21 13:52:06 +00:00
Tiger Wang 742e27ad2f Remove unused Temporary namespace
- Remove unused temporary mapping generation at startup
2020-12-21 00:11:34 +00:00
Tiger Wang 090d8305e4 Warnings improvements
* Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality
* Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already
* Reduced GetStackValue verbosity
+ Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness
+ Give SettingsRepositoryInterface a move constructor to simplify main.cpp code
- Remove do {} while (false) construction in redstone handler
2020-12-18 21:03:40 +00:00
Tiger Wang 83e18f6d31 Horsies: don't always broadcast metadata 2020-12-18 20:44:06 +00:00
Tiger Wang 98cf4025ce BlockInfo: float-equal for Clang only 2020-11-28 20:49:33 +00:00
Tiger Wang 815f2aed82 Lilypads: add missing boundary check 2020-11-28 20:48:53 +00:00
Tiger Wang 0c69b648ae HTTPServerConnection: more robust error handling
* Fix passing a nullptr to downstream code when the request was malformed
+ Reset the connection on errors
* Fixes #5029
2020-11-14 12:24:42 +00:00
Tiger Wang 645fea4237 Players are no longer kicked when clicking on bedrock (#5023)
* Players are no longer kicked when clicking on bedrock
* Fixes #5022
2020-11-06 14:58:47 +00:00
Tiger Wang 1ed782787a Rein in light spread by correcting falloff value
* Fixes #5018
2020-11-02 15:44:23 +00:00
Tiger Wang 6d85435f60 Remove BLOCKENTITY_PROTODEF 2020-10-24 18:49:38 +01:00
Tiger Wang 64442b05f8 cBlockInfo: further cleanup (#5001)
* cBlockInfo: further cleanup

+ Use switch statements instead of lookup in dynamically initialised arrays
- Remove some deprecated bindings

* Update Stubs removing references to BlockInfoArray
2020-10-18 15:37:07 +00:00
Tiger Wang f8d72c8fa9 MUSL stack size (#4995) 2020-10-17 11:31:40 +00:00
Tiger Wang a145980795 Fix Android builds (#4998)
Construct paths relative to the Cuberite sources with PROJECT_SOURCE_DIR, instead of wherever the first CMakeLists.txt file happened to be with CMAKE_SOURCE_DIR.

In Android's case, the latter was in a folder called android/ but that's not the root of the source tree, so any file path built off that root was wrong. This caused file-specific warnings exclusions to fail to apply.
2020-10-15 09:35:44 +00:00
Tiger Wang 21068011c6 Remove SetProperty(...cPlayer)
Enchantment table, anvil windows are already opened one per-player.
2020-10-03 16:54:14 +01:00
Tiger Wang 3917b250b0 Revert travis changes 2020-09-30 22:05:17 +01:00
Tiger Wang 7bc8d2ee26 Upgrade squeelylitecpp to 3.1.1 2020-09-30 22:05:17 +01:00
Tiger Wang f9ac6543ab C++17 stuff 2020-09-30 22:05:17 +01:00
Tiger Wang 429117c1f6 Doors: check power & toggle correctly
* Fixed upper half ignoring its updates
* Fixes #4945
* Fixed doors playing sound effects when they didn't actually toggle
2020-09-28 23:40:19 +01:00
Tiger Wang c9fbb43ac7 HandleEnchantItem: use a lambda (#4944) 2020-09-28 22:38:10 +00:00
Tiger Wang c158569af3 Remove unused Temporary namespace 2020-09-25 14:51:57 +01:00
Tiger Wang 4519469547 Do not call into things we don't own in destructors
- Remove improper accesses in cChunk destructor
* Fixes #4894
2020-09-25 14:51:16 +01:00
Tiger Wang 10bd15a11e Grass spread: check chunk & light validity correctly 2020-09-25 14:51:16 +01:00
Tiger Wang 5bd12814db Put phonograph on right part of visual spectrum 2020-09-25 09:07:34 +00:00
Tiger Wang 7574f68a48 BlockEntity: clarify ConvertToPickups behaviour 2020-09-25 09:07:01 +00:00
Tiger Wang c53a0ba5f6 Unify block entity pickup conversion
- Removed normal BlockHandler knowledge of block entities during conversion
+ Added cBlockEntity::ConvertToPickups that handles it
2020-09-25 09:07:01 +00:00
Tiger Wang 1a60164848 Small cleanup in Jukeboxes
* Fixed creative players not tracking stats, and the code trying to "place" a record when they used one
2020-09-25 09:07:01 +00:00
Tiger Wang a2ecbf6a2e Fix cItems::AddItemGrid adding empty items 2020-09-25 09:07:01 +00:00
Tiger Wang 3edcafdf8b TABS OUT OF BED! TABS IN THE CORRIDORS! 2020-09-23 14:34:15 +01:00
Tiger Wang 71b96ab921 Limit fortune level, style fixes 2020-09-23 14:34:15 +01:00
Tiger Wang 6183b28f93 Implement redstone quasi-connectivity (#4889) 2020-09-21 20:39:58 +01:00
Tiger Wang 80fa364fd7 IBM Z (#4892) 2020-09-20 18:02:00 +00:00
Tiger Wang 5a16620322 Cauldron: backport "use" behaviour to 1.12 (#4902)
* Cauldron: backport "use" behaviour to 1.12
2020-09-20 15:39:17 +01:00
Tiger WangandAlexander Harkness 68cced73af BlockHandler initialisation is a constant expression (#4891)
* BlockHandler initialisation is a constant expression

If we can't make it all namespaces, this is the next best I guess.

+ Tag handlers constexpr, const as needed
+ Inherit constructors
* Privatise handler functions

* More constexpr

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-20 13:50:52 +00:00
Tiger Wang e2e78abdb7 Style, no need to tag struct with s 2020-09-18 16:41:06 +01:00
Tiger Wang 608e7a9950 Remove unused ServerPort argument 2020-09-18 16:41:06 +01:00
Tiger Wang 7f372b12cb Add State enum to protocol 2020-09-18 16:41:06 +01:00
Tiger Wang bf253caab5 Remove unused ServerPort member 2020-09-18 16:41:06 +01:00
Tiger Wang acc399ffb3 Cleanup Protocol classes
* Visibility, static, ordering changes
2020-09-18 16:41:06 +01:00
Tiger Wang c3d2956ba5 BlockHandler: no dynamic allocation (#4862)
* BlockHandler: no dynamic allocation
2020-09-17 14:51:42 +01:00
Tiger WangandAlexander Harkness d9d71e1de6 Rail: avoid invalid game states (#4864)
+ Check CanBeAt
Ref: #4859

Co-authored-by: Alexander Harkness <me@bearbin.net>
2020-09-13 13:44:20 +00:00
Tiger Wang 33f3c18bc1 Beds: derestrict clicking block face (#4863)
Ref: https://github.com/cuberite/cuberite/issues/4860#issuecomment-691545904
2020-09-13 10:58:39 +00:00