Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- #-*- coding: UTF-8 -*-
- ### Legal
- #
- # Author: Thomas DEBESSE <dev@illwieckz.net>
- # License: CC0 1.0
- #
- import struct
- import sys
- size_unsigned_char = 1
- size_unsigned_short = 2
- size_unsigned_int = 4
- size_int = 4
- size_float = 4
- for file_name in sys.argv[1:]:
- print("# file: " + file_name)
- file_blob = open(file_name, "rb")
- header_version = struct.unpack('<i', file_blob.read(size_int))[0]
- print("# header_version: " + str(header_version))
- con_count = struct.unpack('<i', file_blob.read(size_int))[0]
- print("# con_count: " + str(con_count))
- print("# format: x1 z1 y1 x2 z2 y2 rad flags areas dirs userids")
- con_list = [{} for i in range(0, con_count)]
- for i in range(0, con_count):
- verts_bytes = file_blob.read(6 * size_float)
- verts_floats = struct.unpack('ffffff', verts_bytes)
- con_list[i]["verts"] = verts_floats
- for i in range(0, con_count):
- rad_bytes = file_blob.read(size_float)
- rad_float = struct.unpack('f', rad_bytes)[0]
- con_list[i]["rad"] = rad_float
- for i in range(0, con_count):
- flags_bytes = file_blob.read(size_unsigned_short)
- flags_unsigned_short = struct.unpack("H", flags_bytes)[0]
- con_list[i]["flags"] = flags_unsigned_short
- for i in range(0, con_count):
- areas_bytes = file_blob.read(size_unsigned_char)
- areas_unsigned_char = struct.unpack("B", areas_bytes)[0]
- con_list[i]["areas"] = areas_unsigned_char
- for i in range(0, con_count):
- dirs_bytes = file_blob.read(size_unsigned_char)
- dirs_unsigned_char = struct.unpack("B", dirs_bytes)[0]
- con_list[i]["dirs"] = dirs_unsigned_char
- for i in range(0, con_count):
- userids_bytes = file_blob.read(size_unsigned_int)
- userids_unsigned_int = struct.unpack("I", userids_bytes)[0]
- con_list[i]["userids"] = userids_unsigned_int
- file_blob.close()
- for con in con_list:
- for key in con.keys():
- if key == "verts":
- for i in con[key]:
- print(i, end=' ')
- else:
- end = ' '
- if key == "userids":
- end='\n'
- print(con[key], end=end)
- print()
- """
- # file: /home/illwieckz/.local/share/unvanquished/game/maps/chasm-level0.navcon
- # header_version: 2
- # con_count: 2
- # format: x1 z1 y1 x2 z2 y2 rad flags areas dirs userids
- -1623.585205078125 226.0 1772.6363525390625 -1665.3758544921875 76.25360107421875 1898.5557861328125 50.0 1 63 0 0
- -1219.1612548828125 250.0 2232.142578125 -1232.4483642578125 142.98577880859375 2318.962646484375 50.0 1 63 1 0
- """
Add Comment
Please, Sign In to add comment