Commit Graph

5 Commits

Author SHA1 Message Date
Spottedleaf
8ffa40246a Fix NPE in treeFinished()
tryPushTasks returns null when there are no tasks, not
an empty list.
2023-03-03 16:46:03 -08:00
Spottedleaf
bb3f8a4aea Process player chunk loader mid tick at the start of tick
Additionally, process ticket updates as well if either
the mid tick logic did anything or whether we processed
any chunk tasks.

We process the mid tick logic at the start to be consistent
with the inbetween task execution logic (which is not implemented),
and we process ticket updates to ensure that any full status changes
are processed from chunk tasks.
2023-03-02 23:31:59 -08:00
Spottedleaf
bc07c9f31f Fix radius aware executor softlock
The softlock would occur when a dependency tree finished executing
all of its task and searched for the highest dependency tree
to queue tasks from, only to have that such tree be filled
with purged tasks. Because it would select an empty
tree to pull tasks from, it would not select another
tree to execute tasks from as this logic is done after a task
is executed.
2023-03-01 22:22:24 -08:00
Spottedleaf
093b1e5394 Fix several issues, mostly saving pending teleporting entities
The place/portal async function now track entities that have been
removed from the world but have not teleported. When the server
shuts down, these entities will have their passenger tree restored
and re-added to the entity slices at the location they were teleporting to,
or in the case of portals that did not run placeAsync yet,
the location they entered the portal on. This should ensure that
for regular teleports that the entity is placed at its correct
target location, and for portalling to ensure that either
the entity is placed at the portal entrace location (where
they entered) or the portal destination. In any case,
the entity is preserved in a location and will survive
the shutdown.

Additionally, move player saving until after the worlds save. This
is to ensure that the save logic is performed only after
all teleportations have completed.

Fix some other misc issues as well:
 - Fix double nether portal creation by checking if a portal exists again
   before creating it, fixing a race condition where two entites would portal
   and neither would see that the other created a portal.
 - Make all remove ticket add an unknown ticket.
   In general this behavior is better since it means that unloads will only
   ever occur at the next tick, rather than during the tick logic. Thus,
   there will be no cases where a chunk is unloaded unexpectedly.
 - Do not use fastFloor for calculating chunk position from block position
   It is not going to return a good value outside of [-1024, 1024]
 - Always perform mid tick update for ticking regionised player chunk loader
   If no entities were loaded, no chunks were loaded, and nothing else -
   the logic would not have otherwise ran. This fixed some rare cases of
   chunks never loading for players after logging in.
2023-03-01 19:12:31 -08:00
Spottedleaf
19fd3efaa6 Increase parallelism for neighbour writing chunk statuses
Namely, everything after FEATURES. By creating a dependency
chain indicating what chunks are in use, we can safely
schedule completely independent tasks in parallel. This
will allow the chunk system to scale beyond 10 threads
per world.

Currently this patch needs some more testing.
2023-02-26 23:45:21 -08:00