SourceIO icon indicating copy to clipboard operation
SourceIO copied to clipboard

s&box map support

Open izzint opened this issue 4 years ago • 19 comments

Whenever I try to load a s&box VPK map file it gives me this error:


Python: Traceback (most recent call last):
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2_operators.py", line 109, in execute
    world.load(vpk_path.stem)
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\resouce_types\valve_world.py", line 43, in load
    self.load_entities()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\resouce_types\valve_world.py", line 56, in load_entities
    handler.load_entities()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 78, in load_entities
    self.load_all_entities()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 99, in load_all_entities
    self.handle_child_lump(proper_path.stem, ValveCompiledFile(elump_file))
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 103, in handle_child_lump
    self.load_entity_lump(name, child_lump)
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 122, in load_entity_lump
    a.read(reader)
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\utils\entity_keyvalues.py", line 11, in read
    version = reader.read_int32()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\utilities\byte_io_mdl.py", line 171, in read_int32
    return self._read('i')
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\utilities\byte_io_mdl.py", line 156, in _read
    return struct.unpack(t, self.file.read(struct.calcsize(t)))[0]
struct.error: unpack requires a buffer of 4 bytes

location: <unknown location>:-1

izzint avatar Aug 05 '21 16:08 izzint

Please, provide VPK file

REDxEYE avatar Aug 05 '21 16:08 REDxEYE

https://we.tl/t-h7T7GIHVIS

izzint avatar Aug 05 '21 16:08 izzint

Fixed in 84a663928992abe99d3f9c9063261fbb94eafaff

REDxEYE avatar Aug 05 '21 19:08 REDxEYE

Please verify and close ticket

REDxEYE avatar Aug 05 '21 19:08 REDxEYE

seems like it is still not working (used addon from source code instead of releases) error:

Python: Traceback (most recent call last):
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2_operators.py", line 109, in execute
    world.load(vpk_path.stem)
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\resouce_types\valve_world.py", line 43, in load
    self.load_entities()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\resouce_types\valve_world.py", line 56, in load_entities
    handler.load_entities()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 78, in load_entities
    self.load_all_entities()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 99, in load_all_entities
    self.handle_child_lump(proper_path.stem, ValveCompiledFile(elump_file))
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 103, in handle_child_lump
    self.load_entity_lump(name, child_lump)
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\entities\abstract_entity_handlers.py", line 122, in load_entity_lump
    a.read(reader)
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\source2\utils\entity_keyvalues.py", line 11, in read
    version = reader.read_int32()
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\utilities\byte_io_mdl.py", line 171, in read_int32
    return self._read('i')
  File "C:\Users\zoome\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\SourceIO\utilities\byte_io_mdl.py", line 156, in _read
    return struct.unpack(t, self.file.read(struct.calcsize(t)))[0]
struct.error: unpack requires a buffer of 4 bytes

location: <unknown location>:-1

izzint avatar Aug 06 '21 14:08 izzint

it seems like it is the same error

izzint avatar Aug 06 '21 14:08 izzint

The map you provided loads fine for me, are you trying to load a different map? If so, can you send it?

REDxEYE avatar Aug 10 '21 09:08 REDxEYE

Should be fixed now

REDxEYE avatar Aug 16 '21 10:08 REDxEYE

I'm still having issues with this:

[DEBUG]--[ContentManager:find_file]: Requesting maps/devroom01.vmap_c file
[DEBUG]--[ContentManager:find_file]: Found in LooseFilesContentProvider("D:/Project.Files.2025.Q1/TwMCProject/twmc_sbox_levels/Assets")!
[DEBUG]--[ContentManager:find_file]: Requesting maps/devroom01/worldnodes/node000.vrman_c file
[DEBUG]--[ContentManager:find_file]: Found in VPKContentProvider("D:/Project.Files.2025.Q1/TwMCProject/twmc_sbox_levels/Assets/maps/devroom01.vpk")!
[DEBUG]--[ContentManager:find_file]: Requesting maps/devroom01/world.vwrld_c file
[DEBUG]--[ContentManager:find_file]: Found in VPKContentProvider("D:/Project.Files.2025.Q1/TwMCProject/twmc_sbox_levels/Assets/maps/devroom01.vpk")!
[DEBUG]--[ContentManager:find_file]: Requesting maps/devroom01/worldnodes/node000.vwnod_c file
[DEBUG]--[ContentManager:find_file]: Found in VPKContentProvider("D:/Project.Files.2025.Q1/TwMCProject/twmc_sbox_levels/Assets/maps/devroom01.vpk")!
[DEBUG]--[ContentManager:find_file]: Requesting maps/devroom01/entities/default_ents.vents_c file
[DEBUG]--[ContentManager:find_file]: Found in VPKContentProvider("D:/Project.Files.2025.Q1/TwMCProject/twmc_sbox_levels/Assets/maps/devroom01.vpk")!
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\operators\source2_operators.py", line 149, in execute
    load_map(model, content_manager, self.scale)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 48, in load_map
    return import_world(world_resource, map_resource, cm, scale)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 79, in import_world
    load_entities(world_resource, master_collection, scale, content_manager)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 149, in load_entities
    load_entity_lump(entity_resource, handler, collection, scale, cm)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 154, in load_entity_lump
    handler = handler_class(list(entity_resource.get_entities()), collection, cm, scale)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\library\source2\resource_types\compiled_world_resource.py", line 22, in get_entities
    yield EntityKeyValues.from_buffer(buffer)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\library\source2\utils\entity_keyvalues.py", line 142, in from_buffer
    assert version == 1, f"Unknown version of entity keyvalues:{version}"
AssertionError: Unknown version of entity keyvalues:0

PiperManiaDeluxe avatar Dec 03 '24 17:12 PiperManiaDeluxe

SBox is constantly updating, they can change anything about map format. I update sourceio from time to time to support their changes

REDxEYE avatar Dec 03 '24 17:12 REDxEYE

Thanks for the quick reply, would you like more insight on the errors im getting? (even a simple map with a basic mesh and a point light is not importing) or would you like to stop here? I can see how sbox's constant updates can make something like this very frustrating.

PiperManiaDeluxe avatar Dec 03 '24 17:12 PiperManiaDeluxe

You can help by uploading example map

REDxEYE avatar Dec 03 '24 17:12 REDxEYE

Sure! maps.zip

Importing simpletest.vpk on the main branch gives me the following exception:

Python: Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\operators\source2_operators.py", line 148, in execute
    model = CompiledMapResource.from_buffer(map_buffer, vpk_path)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\library\source2\resource_types\resource.py", line 61, in from_buffer
    header = CompiledHeader.from_buffer(inmemory_buffer)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\library\source2\data_types\compiled_file_header.py", line 39, in from_buffer
    assert header_version == 0x0000000c
AssertionError

And on the better_errors branch:

Python: Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\operators\source2_operators.py", line 149, in execute
    load_map(model, content_manager, self.scale)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 48, in load_map
    
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 79, in import_world
    
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 149, in load_entities
    
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\blender_bindings\source2\vwrld\loader.py", line 154, in load_entity_lump
    handler.load_entities()
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\library\source2\resource_types\compiled_world_resource.py", line 22, in get_entities
    yield EntityKeyValues.from_buffer(buffer)
  File "C:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\SourceIO\library\source2\utils\entity_keyvalues.py", line 142, in from_buffer
    assert version == 1, f"Unknown version of entity keyvalues:{version}"
AssertionError: Unknown version of entity keyvalues:0

PiperManiaDeluxe avatar Dec 03 '24 18:12 PiperManiaDeluxe

Interesting, better_errors branch should be the same for parsing code.....

REDxEYE avatar Dec 03 '24 22:12 REDxEYE

Yeah, I've seen that the error the main branch spits out is different on different runs

PiperManiaDeluxe avatar Dec 04 '24 01:12 PiperManiaDeluxe

I think i fixed it, can you please try again?

REDxEYE avatar Dec 04 '24 12:12 REDxEYE

Will do once I can

PiperManiaDeluxe avatar Dec 04 '24 23:12 PiperManiaDeluxe

Its not giving me any errors this time but all that gets imported is a single empty with the name of one of the world nodes, no entities or meshes get imported.

PiperManiaDeluxe avatar Dec 05 '24 16:12 PiperManiaDeluxe

It did work for me, could you please share the blend file and logs?

REDxEYE avatar Dec 05 '24 16:12 REDxEYE