1
0
Fork 0
Commit Graph

531 Commits

Author SHA1 Message Date
Rorkh 6bbbc52d02
Permission-based player chat message formatting (#5304)
+ Permissions for chat message format access
2021-09-23 21:49:34 +01:00
Ethan Jones 7b0872aecc
BungeeGuard style proxy security and OnlyAllowBungee config (#5291) 2021-09-23 21:09:52 +01:00
Ethan Jones 3b47eaadb8
Ignore dead movement (#5292)
* Ignore player updates from dead players #5289

* move the condition down a bit, add parentheses

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-09-16 07:31:16 +00:00
Ethan Jones 9712c5507c
Don't allow players in adventure mode to break blocks (#5293) 2021-09-15 17:33:45 +00:00
Tiger Wang 11ca2cf4c0 Disconnect: call HandleOutgoingData one last time
* Fixes #5285
2021-08-26 21:55:09 +01:00
Mattes D 179d6da490
Setting command-block's command requires a permission. (#5270) 2021-07-20 18:48:05 +00:00
KingCol13 1d1fa91401
Chorus fruit teleport (#5259)
* Outline function for teleporting.

* Created new handler for chorus fruit.

* Fixed AttemptTeleport failing.

* Better names, working sound effect.

* Corrected naming.

* Remove stray LOGD.

* Offset teleport to middle of block.

* Style Fixes

Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com>

* Style Fixes 2

Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com>

* Move FindTeleportDestination to static cPawn method.

* cBoundingBox interface.

* Cleanup includes.

* Maybe exported to API?

* Change a_World to reference, add to APIDesc.

Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com>
2021-07-10 20:05:00 +00:00
Tiger Wang e9265b1d01
Symmetry in MultiVersionProtocol to fix a crash (#5261)
+ Add HandleOutgoingData, which tests for m_Protocol before calling DataPrepared.
* Change std::function to bool + if/else to handle incoming data; it's almost certainly faster.
* Fixes #5260
2021-07-10 20:04:49 +00:00
Tiger Wang fe82551f32 Replace chunk coordinates magic with numeric_limits 2021-07-06 21:33:03 +01:00
Tiger Wang 06a2b1211b Invalidate m_LastStreamedChunk when player position doesn't match
So teleporting to and back doesn't cause chunk sending to stop.

* Fixes #4531
2021-07-06 21:33:03 +01:00
Tiger Wang e735faf755 Protocol: call the encryptor once before sending data 2021-07-06 21:33:03 +01:00
Tiger Wang 8a08b3d3b7 Remove outdated comment and redundant check
Refactoring made the comment no longer true.
The check isn't needed since no packets are sent, and Destroy does nothing, if m_HasSentDC.
2021-07-06 21:33:03 +01:00
Tiger Wang 04f02a675d Protocol: use dedicated packet for 1 block change
It's six bytes smaller.
2021-06-28 21:54:21 +01:00
Tiger Wang a62b2b1be2
Move item placement into item handlers (#5184)
* Move item placement into item handlers

+ Add appropriate CanBeAt checks in cPlayer::PlaceBlocks, into which all placement handlers call.
* Partly addresses #5157
* Fixes #4878
* Fixes #2919
* Fixes #4629
* Fixes #4239
* Fixes #4849

Co-authored-by: changyong guo <guo1487@163.com>
Co-authored-by: Xotheus <shady3300@outlook.com>
Co-authored-by: Krist Pregracke <krist@tiger-scm.com>

* Review fixes

* Update APIDesc.lua

* Rename

Co-authored-by: changyong guo <guo1487@163.com>
Co-authored-by: Xotheus <shady3300@outlook.com>
Co-authored-by: Krist Pregracke <krist@tiger-scm.com>
2021-05-05 13:25:10 +00:00
nshah25 8be1dd54bb
Add player statistics to API (#5193)
* Fixed issue #5166

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-05-03 21:07:09 +01:00
Tiger Wang a999c5d845 More cProtocol cleanup
* Alpha sort functions
* Simplify hand handling
* Fix left handed mode client-side display
2021-04-12 22:35:07 +01:00
Tiger Wang 2fc86476ae Improve bed handling robustness
+ Boot the player out if the bed was destroyed
2021-04-12 22:35:07 +01:00
Tiger Wang 66c211c33a Unify multiprotocol entity animations 2021-04-12 22:35:07 +01:00
Tiger Wang 1394fc8eb5 Streamline player abilities handling
* Update player list gamemode on world change
* Fix invisibility for spectators, use entity metadata
* Populate m_World for cPlayers on load
- Remove SendPlayerMaxSpeed, a duplicate of SendEntityProperties
2021-04-12 22:35:07 +01:00
Tiger Wang 0f9d424427 Fix block break particles 2021-04-12 22:35:07 +01:00
Tiger Wang 4cd49d7eca Fix sending incorrect date values on world change
Yak shave: make more things use cTickTime. Fix a couple of incorrect modulo-on-millisecond-value by making them use WorldTickAge.
2021-04-12 22:35:07 +01:00
Damián Imrich 071b7be3d4
Basic elytra flight (#5124)
* Basic elytra flight

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-04-03 18:45:20 +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 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 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 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 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
12xx12 8405b8969f
Adding Boss bar (#5025)
+ Add boss bar

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2021-03-05 15:08:30 +00:00
dImrich 925f960ea2 Adds playerlist header and footer broadcasting (1.8-1.13) 2021-02-06 14:14:40 +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 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 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 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 d9a7c51d4d ViewDistance: unsigned -> signed 2020-12-26 16:58:53 +00:00
mathiascode 2103308618 Ignore CanFly flag sent by the client 2020-12-18 21:03:50 +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 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
12xx12 3381c0f6d6
Merged OnBreak with OnPlayerBreak (#4967)
Co-authored-by: 12xx12 <12xx12100@gmail.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-08 20:13:44 +01:00
peterbell10 a9031b6bae
Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963)
* Fix cmake not adding Werror on clang, and _lots_ of warnings

* WIP: Build fixes

* Cannot make intermediate blockhandler instance

* Tiger's changes

* Fix BitIndex check

* Handle invalid NextState values in cMultiVersionProtocol

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-05 10:27:14 +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
KingCol13 cd1b507745
Fix instant mining of blocks not being recognised, tweak anti-cheat (#4938)
* Tried to fix a small issue...

Ended up rewriting a bunch of god awful, opaque code with no source
and no sense. Who names a function GetPlayerRelativeBlockHardness???
It's gone now. We're safe again.

* Testing anti-cheat.

* Tidy up debug logging.

* Remove empty member declaration.

* Rewrite GetDigSpeed slightly for better readability.

* GetMiningProgressPerTick now returns 1 when instantly mined. Fixed hasily written typo.

* Comment style and typo fixes.
2020-10-02 20:57:17 +00:00
KingCol13 8947147c25
Enchanting table shows detail on hover. Enchanting is deterministic. (#4937)
* Use lapis for enchanting, subtract correct number of levels, ClientHandle now selects from pregenerated list.

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-10-01 22:33:32 +01:00
Tiger Wang c9fbb43ac7
HandleEnchantItem: use a lambda (#4944) 2020-09-28 22:38:10 +00:00
KingCol13 32af227fa7
Enchanting consumes lapis, removes correct number of levels (#4934)
* Use lapis for enchanting, subtract correct number of levels.
* Enforced distancing regulation better than our government.

Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
2020-09-28 00:51:23 +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