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

Jumping with pipeworks mod enabled saves the whole tp-tube database (instead of just 2 entries) #111

Closed
2 tasks
BuckarooBanzay opened this issue Jan 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@BuckarooBanzay
Copy link
Member

BuckarooBanzay commented Jan 12, 2024

Causes lag spikes up to multiple seconds on larger tp-tube databases 30k+

TODO:

Relevant code sections

Move code:

jumpdrive.teleporttube_compat = function(from, to)
if not pipeworks.tptube then
-- only works with the patch from "./patches/pipeworks.patch"
return
end
local from_hash = pipeworks.tptube.hash(from)
local to_hash = pipeworks.tptube.hash(to)
-- swap data
local db = pipeworks.tptube.get_db()
local data = db[from_hash]
if not data then
minetest.log("warning", "[jumpdrive] no tp-tube data found at hash: " ..
from_hash .. " / pos: " .. minetest.pos_to_string(from))
return
end
minetest.log("action", "[jumpdrive] moving tp-tube data from " ..
from_hash .. " to " .. to_hash .. " at pos: " .. minetest.pos_to_string(from))
data.x = to.x
data.y = to.y
data.z = to.z
db[from_hash] = nil
db[to_hash] = data
end

"commit" after jump:

pipeworks.tptube.save_tube_db()

Pipeworks tp tube api (can be shortened):
https://github.com/mt-mods/pipeworks/blob/dd6950f7b037d17895d41db2bbbddfdfddcdf25c/teleport_tube.lua#L355-L370

@BuckarooBanzay BuckarooBanzay added the bug Something isn't working label Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant