Skip to content

Instantly share code, notes, and snippets.

@devdave
Created February 4, 2023 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdave/f101474a300a8fbe73734dc394f9d7e7 to your computer and use it in GitHub Desktop.
Save devdave/f101474a300a8fbe73734dc394f9d7e7 to your computer and use it in GitHub Desktop.
A short snippet to seek through a valheim db file and retrieve a lit of portals
# sourced from https://www.reddit.com/r/valheim/comments/lixlu7/any_way_to_look_up_the_name_of_a_portal_you_forgot/iibfmuo/
import mmap
def portals(dbfile):
db = open(dbfile, 'rb')
mm = mmap.mmap(db.fileno(), 0, prot=mmap.PROT_READ)
i, l = 0, set()
while True:
i = mm.find(b'\xea\x91|)', i)
if i == -1:
break
l.add(mm[i+5:i+5+mm[i+4]].decode())
i += 5 + mm[i+4]
return l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment