* 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>
Some games provide users with enough freedom to create items
with metadata longer than 64KB, preventing this from causing
issues is on them but we'll still do the minimum not to abort
the server if this happens.
This commit clarifies the maximal length of the serialized strings.
It will avoid accidental use of serializeString() when a larger string can be expected.
Removes unused Wide String serialization functions
Move LuaEntitySAO to a new dedicated file
Drop TestSAO (useless object)
Drop the old static startup initialized SAO factory, which was pretty useless.
This factory was using a std::map for 2 elements, now just use a simple condition owned by ServerEnvironment, which will be lightweight, that will also drop a one time useful test on each LuaEntitySAO creation. This should reduce server load on massive SAO creation
This fix consists of two parts:
- Clear the list of stored entities. This has no side-effects.
- Catch the case where active entities exist and print a message.
Clearing the active entitiy list has side-effects that should
be handled. (those entities are known to the environment and
to clients).
As avoiding those side-effects is more complex, and as this
problem is not expected to occur (with PR #4847 merged), there
is no real incentive to implement this ATM.
This issue was a contributing factor to bug #4217. With the other
contributing factor removed (PR #4847), this commit makes sure this
factor does not go unnoticed if it ever happens again.
* isFreeServerActiveObjectId is now part of ServerEnvironment
* getFreeServerActiveObjectId is now part of ServerEnvironment
* StaticObject constructor now take ServerActiveObject instead of type + string. This permits to remove a big string copy in some code parts
* Modernize source code: last par
* Use empty when needed
* Use emplace_back instead of push_back when needed
* For range-based loops
* Initializers fixes
* constructors, destructors default
* c++ C stl includes
Because the count is serialized as u16, this would cause overflow.
If minetest later deserialized a mapblock with an incorrect
static object count, it would be unable to find the NameIdMapping
(which comes after the StaticObjectList) and abort with an error
such as "Invalid block data in database: unsupported NameIdMapping
version" (issue #2610).
nodemetadata.cpp, nodetimer.cpp
optimzation: simpler deserialize node position method
staticobject.cpp:
cleanup: use util/serialize.h inlines instead of its own de/serialization
serialize.cpp:
minor optimization/cleanup: avoid generation of unneeded string temporary
CMakeLists.txt, cmake_config.h.in: detection of endian.h
config.h: added HAVE_ENDIAN_H
Commits due to feedback squashed
Signed-off-by: Craig Robbins <kde.psych@gmail.com>