Created
February 4, 2023 21:46
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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