Partially address #13483. Server operators can set a minimum
protocol version to match the game requirements (or any other
restriction they may want), and it's applied as an additional
constraint on top of the baseline compatibility range, optional
strict_protocol_version_checking, and any kick-on-join used by
the game/mods.
This improves the reliability when removing and re-adding handles quickly.
Looping through the entire ID range avoids collisions caused by any race condition.
This should improve compilation speed.
Things changed:
* Prefer forward-declarations in headers.
* Move header-includes out of headers if possible.
* Move some functions definitions out of headers.
* Put some member variables into unique_ptrs (see Client).
* refactoring(StaticObjectList): don't expose m_active and m_stored anymore
This prevents our old crap code where anyone can access to StaticObjectList. use proper modifiers. It also permits to do a short cleanup on MapBlock using a helper
* refactoring(MapBlock): reduce a bit exposed m_active_blocks variable
* refactoring: MapBlock::m_node_timers is now private
We already had various helpers to perform this privatization, just use it. Also factorize the MapBlock stepping code for timers using already existing code and importing them from ServerEnvironment to MapBlock.
It's currently done pretty straight forward without any inheritance as MapBlock is just used everywhere, maybe in a future we'll have ServerMapBlock over MapBlock. Currently for a simple function let's just use proper objects and add a comment warning
* refactoring(Server): fix duplicated function for add/remove node
* refactoring(guiFormSpecMenu): add removeAll function to prevent duplicated code
* refactoring(ShadowRenderer) + perf: code quality + increase performance
* All callers are already using the point and we should never test a function with nullptr node, it's a bug. Removed workaround which was hacky and fix the bug
* Drop clientmap lookup from shadowrendered, just use directly its
pointer and forbid to push it in the generic list
* Reduce memory pressure on the renderShadowObject by preventing
deallocating and reallocating multiple vectors on each node
* refactoring(MapBlock): reduce exposure of MapBlock::m_static_objects
It's not complete as some parts of the code are pretty nested, but it's better than before :)
* fix: better working on new functions & drop unwanted 2 lines
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
Dropped ServerSoundParams -> moved to ServerPlayingSound. This gets rid of the duplicated
'fade' and 'pitch' values on server-side where only one was used anyway.
SimpleSoundSpec is the basic sound without positional information, hence 'loop' is included.
Recursively added PROTOCOL_VERSION to most functions to reduce the versioning mess in the
future. Per-type version numbers are kept for now as a safety rope in a special case.
This reduces the
(absolute) time spent in Server::SendBlocks() from 700ms to 300ms
(relative) share of MapBlock::serialize() from 80% to 60%
in a test setup with 10 players and many block changes
The only valid usecase for these is interfacing with OS APIs
that want a locale/OS-specific multibyte encoding.
But they weren't used for that anywhere, instead UTF-8 is pretty
much assumed when it comes to that.
Since these are only a potential source of bugs and do not fulfil
their purpose at all, drop them entirely.
Remove old defaults system
Introduce priority-based fallback list
Use new functions for map_meta special functions
Change groups to use end tags
Unittest changes:
* Adapt unittest to the new code
* Compare Settings objects
Features:
* Define Minimap available modes (surface/radar, scale) from Lua, using player:set_minimap_modes()
* New HUD elements for displaying minimap with custom size and placing
* New minimap mode for displaying a texture instead of the map
* Server::overrideDayNightRatio doesn't require to return bool
There is no sense to sending null player, the caller should send a valid object
* Server::init: make private & cleanup
This function is always called before start() and loads some variables which can be loaded in constructor directly.
Make it private and call it directly in start
* Split Server inventory responsibility to a dedicated object
This splits permit to found various historical issues:
* duplicate lookups on player connection
* sending inventory to non related player when a player connects
* non friendly lookups on detached inventories ownership
This reduce the detached inventory complexity and also increased the
lookup performance in a quite interesting way for servers with thousands
of inventories.