Commit Graph

130 Commits

Author SHA1 Message Date
sfan5 bc4ab8b99e General code refactoring/improvements in server, treegen and connection 2024-03-20 16:37:32 +01:00
sfan5 dfba79f8ff Split servermap.cpp/h off from map.cpp/h 2024-03-20 16:37:32 +01:00
sfan5 178943b4b7 Improve ServerEnvironment::getRemovedActiveObjects() in many ways 2024-03-20 16:37:32 +01:00
sfan5 e3b9828f24 Add unit tests for SAO load / unload behaviour 2024-03-17 15:55:24 +01:00
sfan5 8339594206 Handle static_save changes at runtime and between restarts 2024-03-17 15:55:24 +01:00
sfan5 2386bfda7e Fix static_save=false not working & related cleanups 2024-03-17 15:55:24 +01:00
sfan5 ef0009aea7 Sort out server destruction order
fixes #14421
2024-03-17 15:55:24 +01:00
SmallJoker 32f68f35cf
Avoid packets getting sent to disconnected players (#14444)
Many functions expect RemotePlayer to have a valid peer ID,
this however is not the case immediately after disconnecting
where the object is still alive and pending for removal.

ServerEnvironment::getPlayer(const char *, bool) now only
returns players that are connected unless forced to.
2024-03-10 13:24:35 +01:00
Lars Müller bf52d1e624
Fix attached sounds stopping if objects are removed serverside (#14436)
Restores backwards compatibility for death sounds or other sounds that are not supposed to be "cut off" abruptly.

---------

Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: grorp <gregor.parzefall@posteo.de>
2024-03-06 20:36:02 +01:00
sfence 63a9853811
Remove attached sounds when the active object is removed (#14341) 2024-02-25 22:10:39 +00:00
sfan5 2b97fead9e Fix some potential iterator invalidation issues 2024-02-16 12:34:40 +01:00
sfence 83f779c52d
Fix active object adding to not generated block (#14311) 2024-02-04 21:24:08 +01:00
Lars Müller 1d9c9710d7
Fix short raycasts missing large objects (#14339)
Increases the tolerance from one node to five nodes.
Also optimizes the "sphere" used for pre-filtering entities
to start in the middle of the line segment rather than at the start.
2024-02-04 14:04:05 +01:00
SmallJoker e7dbd325d2
RemotePlayer: make peer ID always reflect the validity of PlayerSAO (#14317)
Upon disconnect, RemotePlayer still had a peer ID assigned even though
the PlayerSAO object was maked as gone (for removal). This commit makes
that the following always holds true:

	(!sao || sao->isGone()) === (peer_id == PEER_ID_INEXISTENT)
2024-02-02 22:13:24 +01:00
cx384 5958714309
Tool specific pointing and blocking pointable type (#13992) 2024-01-22 18:27:08 +01:00
lhofhansl 59abf1bb42
Allow active blocks to be generated (#14185) 2024-01-13 10:27:41 -08:00
sfan5 431444ba9f Extend sanity checks in ActiveBlockList::update
also fixes the space indentation
2023-12-30 00:31:03 +01:00
lhofhansl c99196d363
Do not emerge blocks in the active_object_send_range_blocks range (#14152)
The active object range is about active objects (not blocks). Activate blocks (and hence any object "in" them) in the cone define by the active object range (and fov) when they are loaded (i.e. visible), otherwise ignore them.
2023-12-29 14:18:06 -08:00
sfan5 777dca7043 Elide MapBlock::contents_cached 2023-12-16 12:51:42 +01:00
sfan5 c6cf90f67b Change MapBlock content cache to a vector 2023-12-16 12:51:42 +01:00
DS 6106e4e72b
Fix sound and particlespawner id generation (#14059)
* Fix server sound ids being reused to early

* Fix particlespawner id generation

It always returned 0.
Also, now the ids always grow, to make a conflict with ids in lua unlikely.
2023-12-01 00:09:53 +01:00
SmallJoker a7e5456099
Server: avoid re-use of recent ParticleSpawner and Sound IDs (#14045)
This improves the reliability when removing and re-adding handles quickly.
Looping through the entire ID range avoids collisions caused by any race condition.
2023-11-29 21:10:19 +01:00
DS 11ec75c2ad
ActiveObjectMgr fixes (#13560) 2023-10-09 17:13:04 +02:00
sfan5 c3114132d3
Improve readability and infos in verbose log (#13828) 2023-09-22 18:41:10 +02:00
Gregor Parzefall 26453df2f7
Don't crash if a Lua error occurs inside get_staticdata 2023-07-03 20:34:02 +02:00
numzero 3b74cc4a41 Replace PP with direct printing 2023-06-26 22:51:32 +02:00
lhofhansl a8ec6092e2
Load blocks and objects behind player when in third-persion front-view (#13431) 2023-05-29 10:26:42 -07:00
Desour 7f6b09dce8 Use json forward-declarations 2023-04-27 18:50:33 +02:00
DS ed632f3854
Safely handle block deletion (#13315)
Co-authored-by: Jude Melton-Houghton <jwmhjwmh@gmail.com>
2023-03-24 12:34:44 +01:00
Jude Melton-Houghton b7359f5fa9 Update nodes in LBM loop 2023-03-13 18:17:07 +01:00
Jude Melton-Houghton 5c248c2d7d Add callback on_mapblocks_changed 2022-12-24 08:24:59 -05:00
sfan5 37386b9c3c
Expose dtime_s to LBM handler 2022-12-04 12:35:14 +01:00
Jude Melton-Houghton 3fd5bff128
Abort active ABM iteration when content changes (#12998) 2022-11-27 15:55:10 -05:00
lhofhansl 1a045da0dd
Reduce active mgmt interval for a bit when a player joins. (#12925) 2022-11-10 15:25:38 -08:00
Abdou-31 d1b80b462e
Fix typos and en_US/en_GB inconsistency in various files (#12902) 2022-11-09 11:57:19 -05:00
Loïc Blot 322c8cf270
Reduce exposure of various internals (#12885)
* 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>
2022-11-03 17:35:31 +01:00
Lars Müller 077627181e
Allow rotating entity selectionboxes (#12379) 2022-10-30 16:53:14 +01:00
lhofhansl 9aaed75eea
Safety check the map's blocksize (#12895) 2022-10-27 19:31:42 -07:00
Jude Melton-Houghton 8f996e4a7c Remove unused MapBlock functionality 2022-10-09 13:43:48 -04:00
savilli 907dcdcf7b
Add unittests for item movement code (#11885) 2022-09-27 16:22:11 -04:00
sfan5 14c283a623 Fix crash in commit a69b7abe00 2022-06-05 19:00:14 +02:00
sfan5 a69b7abe00 Improve LBMManager::applyLBMs() code
Fixes a possible bug for lbms on content ID zero and removes unsafe casts.
2022-06-05 17:48:51 +02:00
sfan5 c1d03695d4 Minor code improvements around active block keeping 2022-05-29 14:00:19 +02:00
sfan5 ea74680df4 Immediately activate blocks when a player joins
issue: #10884
This makes it possible for objects to immediately be activated,
but doesn't guarantee it since blocks may still need be emerged.
2022-05-29 14:00:19 +02:00
sfan5 f5a8593b11
Add more Prometheus metrics (#12274) 2022-05-09 21:20:58 +02:00
sfan5 e7659883cc Async environment for mods to do concurrent tasks (#11131) 2022-05-02 20:56:06 +02:00
sfan5 a65f6f07f3 Clean up some auth packet handling related code 2022-04-28 20:05:26 +02:00
ShadowNinja 7993909fab Spacing fixes 2022-04-08 14:55:21 +01:00
sfence b10091be9b
Add min_y and max_y checks for Active Block Modifiers (ABM) (#11333)
This check can be used by ABM to reduce CPU usage.
2021-06-20 17:21:35 +02:00
SmallJoker c9144ae5e2
Add core.compare_block_status function (#11247)
Makes it possible to check the status of the mapblock in a future-extensible way.
2021-05-30 20:24:12 +02:00