Skip to content

Grav ship cache#906

Draft
Sakura-TA wants to merge 5 commits intorwmt:devfrom
Sakura-TA:GravShipCache
Draft

Grav ship cache#906
Sakura-TA wants to merge 5 commits intorwmt:devfrom
Sakura-TA:GravShipCache

Conversation

@Sakura-TA
Copy link
Copy Markdown
Contributor

@Sakura-TA Sakura-TA commented May 6, 2026

This patch is to cache the gravship search result wisely.
default in vanilla, a redo of search is happening when one of the following situation is matched:

  1. cached gravship is not in map currently searching
  2. cached tick is not current tick

Means in the following situation it always do the search and iter through all the items:

  1. player don't have a ship in the map currently searching.
  2. player have a ship in this map but the search haven't been done in this tick yet.
  3. player have a ship in this map and cached but another ship in other map recached and took the cache slot so a mis-cache happens.

This patch use cache to prevent all-item-iter happens in these 3 situation.

  1. Only allowed 1 call per-map-per-tick if there's no gravship.(instead of do the search for every call in same tick)
  2. Check if gravship previously cached is still available and reuse it.(instead of do the search every tick)
  3. Fix by using per-map-cache.

It's working fine to me for now and fixed the problems I mentioned here, but I believe further works is still available on it, like "check the gravship's ownership" or "make 2 ships on same map clearly independent", So I'll draft this PR here for a little while before I'm sure with what should be added here, and also for a longer test.

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