Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no squash] Optimizations and code quality improvements #83

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Emojigit
Copy link
Member

@Emojigit Emojigit commented Oct 25, 2024

This PR optimizes some parts and improves code quality by following lua_api.md recommendations.

Check individual commits for what this PR does and why the changes are made.

For "Prevent saving entities": Due to how static_save = false works, old entities may linger but disappear after punching them or restarting the server again.

This PR is ready for review.

This eliminates the need of iterating the whole list for every protection operations. Note that the highest index isn't cached, i.e. the first or few (if there are many holes) operations would still suffer from the lag.
On newer Minetest servers, handles saving jobs in async environment. To prevent conflicts, the save file is locked whie saving, and if a code requests saving while the file is locked, data is saved again immediately after finishing the current save.
startTime is not used anywhere else, so localizing it makes sense and saves memory.
This may add lag, but stops saving entities (which lua_api.md discourages). This also eliminates areas.markPos{1,2} (which seemed to be internal) and integrates areas:setPos{1,2} with such function.
Merges "pos1" and "pos1only" into the same code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant