niftools / pyffi

PyFFI is a Python library for processing block structured files.
http://www.niftools.org/pyffi
Other
47 stars 26 forks source link

struct.error when reading nif.xml #67

Open FeuerTiger86 opened 4 years ago

FeuerTiger86 commented 4 years ago

@niftools/blender-nif-plugin-reviewer -

Before creating a new issue, ensure that

The issue will get closed off immediately as invalid if

Fill out the template below to the best of your ability, including .blend files, nifs, logs; help us to help you.

Issue Overview

Plugin doesn't work with the portable (zip) version of Blender 2.79b.

Version Information

Blender Nif Plugin Version Info

2.6.0a0.dev4-2019-11-24

Blender Version Info

2.79b portable (zip)

Platform information

Windows 10 Professional 64bit

Context

Unfortunately, Blender 2.79b cannot be installed alongside 2.8x and is automatically uninstalled when installing the new version. Therefore I tried using the portable (zip) version of 2.79b instead, which does not need to be installed and works with 2.8x installed at the same time.

However, the nif plugin no longer works in this version, as I get this error when trying to import a model:

struct.error: unpack requires a bytes object of length 2
ERROR:pyffi.nif.data:Reading <struct 'NiTriShapeData'> failed

The console shows a lot more messages related to the various .py files and in the end it says:

location: <unknown location>:-1

Exporting does not produce an error, but the model is not exported correctly and cannot be opened in Nifskope.

I tried uninstalling 2.8x and installing 2.79b again, but the installer says a newer version is already installed and exits.

Steps to Reproduce

Happens whenever I import or export a model.

Expected Result

See above.

Actual Result

See above

Possible Fix

Screenshot

Logs and Files

Info Bar Output

bpy.data.window_managers["WinMan"].addon_search = "nif"
bpy.ops.object.select_all(action='TOGGLE')
bpy.ops.object.select_all(action='TOGGLE')
bpy.ops.object.delete(use_global=False)
bpy.context.space_data.recent_folders_active = 0
bpy.context.space_data.recent_folders_active = 1
bpy.context.space_data.recent_folders_active = 1
Executing - Niftools : Blender Nif Plugin v2.6.0 (running on Blender 2.79 (sub 0), PyFFI 2.2.4.dev2)
Importing D:\Spiele\Bethesda Softworks\Morrowind_EV_GOG\Data Files\Meshes\o\contain_barrel10.nif
NIF file version: 67108866
Reading file
Finished
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\operators\nif_import_op.py", line 156, in execute
    return nif_import.NifImport(self, context).execute()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\nif_import.py", line 110, in execute
    self.data = NifFile.load_nif(NifOp.props.filepath)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\io\nif.py", line 64, in load_nif
    nif_data.read(nif_stream)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\formats\nif\__init__.py", line 1383, in read
    block.read(stream, self)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\array.py", line 303, in read
    elem.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\common.py", line 167, in read
    stream.read(self._size))[0]
struct.error: unpack requires a bytes object of length 2

location: <unknown location>:-1

Console Output

pyffi.nif.data:ERROR:Reading <struct 'NiTriShapeData'> failed
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\formats\nif\__init__.py", line 1383, in read
    block.read(stream, self)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\array.py", line 303, in read
    elem.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\common.py", line 167, in read
    stream.read(self._size))[0]
struct.error: unpack requires a bytes object of length 2
ERROR:pyffi.nif.data:Reading <struct 'NiTriShapeData'> failed
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\formats\nif\__init__.py", line 1383, in read
    block.read(stream, self)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\array.py", line 303, in read
    elem.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\common.py", line 167, in read
    stream.read(self._size))[0]
struct.error: unpack requires a bytes object of length 2
Traceback (most recent call last):
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\operators\nif_import_op.py", line 156, in execute
    return nif_import.NifImport(self, context).execute()
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\nif_import.py", line 110, in execute
    self.data = NifFile.load_nif(NifOp.props.filepath)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\io\nif.py", line 64, in load_nif
    nif_data.read(nif_stream)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\formats\nif\__init__.py", line 1383, in read
    block.read(stream, self)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\array.py", line 303, in read
    elem.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\xml\struct_.py", line 373, in read
    attr_value.read(stream, data)
  File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_scene_nif\dependencies\pyffi\object_models\common.py", line 167, in read
    stream.read(self._size))[0]
struct.error: unpack requires a bytes object of length 2

location: <unknown location>:-1

location: <unknown location>:-1

Blend File

Happens for every model

Nif File

Happens for every model

Similar Known Issues

Additional Information

neomonkeus commented 4 years ago

@Pherim Please fill in the info as per the template.

FeuerTiger86 commented 4 years ago

Sorry! Should be better now.

neomonkeus commented 4 years ago

Can you attach the nif in question.

FeuerTiger86 commented 4 years ago

Ok, I thought it would happen with every nif, but it seems it only happens with Morrowind ones - I tested Oblivion and Skyrim as well, and the import seems to work.

Here is the one I used in the logs. It's from a mod, but the same happens with meshes from the original game. This was just the first one I came across. contain_barrel_01.zip

neomonkeus commented 4 years ago

This seems to be a pyffi issue (the library used to read/write the nifs).

neomonkeus commented 4 years ago

@HENDRIX-ZT2 This could be an issue with the version of nif.xml, tested with both v7.1.0 & v0.7.1.1