Skip to content

Instantly share code, notes, and snippets.

@xaedes
Created February 9, 2023 23:16
Show Gist options
  • Save xaedes/f7bf2dba0f0c0e3a22c974e7e0f585ea to your computer and use it in GitHub Desktop.
Save xaedes/f7bf2dba0f0c0e3a22c974e7e0f585ea to your computer and use it in GitHub Desktop.
List Valheim Portal Names of given db file
#!python
import mmap
import argparse
def portals(dbfile):
with open(dbfile, 'rb') as db:
mm = mmap.mmap(db.fileno(), 0, access= mmap.ACCESS_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
def main():
parser = argparse.ArgumentParser()
parser.add_argument('file', type=str)
options = parser.parse_args()
print("File:", options.file)
print("Portals:")
for portal in sorted(portals(options.file)):
print(portal)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment