Author Topic: Map Packaging Tool?  (Read 3341 times)

jitspoe

  • Administrator
  • Autococker
  • Posts: 18801
Map Packaging Tool?
« on: March 26, 2014, 05:02:58 PM »
I was thinking of making a tool that would allow you to quickly (ex: drag and drop) take a map and zip up the map and all of its dependencies, and warn about missing files and such.  Then I thought, "That's something somebody in the community could probably do!"

Here's what I had in mind:

Drag and drop the BSP file onto the program, and it would:

- Verify that the map is in the appropriate directory and add it into the appropriate directory in the zip file (ex: pball/maps/beta).
- Load the map and check all textures for non-standard textures, add the textures to the zip, verify that low res textures are available for all textures, verify that all textures are power of 2 resolutions.
- Check "requiredfiles" in worldspawn and add any necessary files there (if an r_script, add all texture dependencies within the rscript and verify that the low res textures are there, the textures are powers of two, etc. as above).
- Check "func_models", and add any non-standard md2 or skm files, along with dependencies (skp, texture files, etc.)
- Check "sky" in worldspawn and include any non-standard env files (and verify that low res versions are available, power of 2, etc.)
- Check for mapinfo file and include if available.
- Check for mapshot file and include if available.

That would make it a lot easier for mappers using custom content, and there could be an automated way of verifying that all the necessary files are included and set up properly, and no unnecessary files are included.

ViciouZ

  • Map Committee
  • Autococker
  • Posts: 2227
Re: Map Packaging Tool?
« Reply #1 on: March 26, 2014, 06:12:42 PM »
I used to have a PHP library for manipulating BSP files and getting all the texture names etc. but I appear to have misplaced it or outright deleted it. It was going to be part of the maps database on banterous, so you could download a map with all the dependencies at once in a zip.

Edit: Nvm, found it. If anyone wants the code, let me know, here is an example of the kind of data it can extract at present:
Code: [Select]
basic bspInfo class test
file: test.bsp

test 1: basic lump contents info
num planes: 9900
num vertices: 11455
num faces: 9467
num nodes: 6606
num texinfos: 237
num leaves: 6610
has vis data: yes
has lightmap: yes

test 2: list of texture names
Array
(
    [pball/bark1_1] => 38
    [pball/rrock1_2] => 28
    [pball/city6_8] => 18
    [pball/rockj1_2] => 16
    [pball/box3] => 14
    [pball/clip] => 12
    [pball/grass1_4] => 11
    [pball/ground1_2] => 9
    [pball/b_metal1] => 9
    [pball/dung01_3] => 8
    [pball/sand1] => 8
    [pball/uwall1_3] => 7
    [pball/water5] => 7
    [pball/dung01_5] => 6
    [pball/ltwhite] => 6
    [pball/grass1_8] => 6
    [pball/lit3_5] => 5
    [pball/b_brt1] => 4
    [pball/r_brt1] => 4
    [pball/doorp1] => 4
    [pball/r_metal1] => 3
    [pball/grassp5] => 3
    [pball/b_brl1] => 3
    [pball/sky1] => 3
    [pball/r_brl1] => 3
    [pball/b_flag1] => 1
    [pball/r_flag1] => 1
)

test 3: entity list
Array
(
    [0] => Array
        (
            [message] => Archaic Fields -- By: Shreds?-=R=-]
            [sky] => riverscape1
            [classname] => worldspawn
        )

    [1] => Array
        (
            [origin] => -2560 0 64
            [angle] => -2
            [classname] => info_player_start
        )

<snip>

    [235] => Array
        (
            [origin] => -96 -176 160
            [type] => steel
            [classname] => item_pballbarrel
        )

)

test 4: lightmap extraction
average luma: 68.6830424576
map is predominantly light

end of test

xrichardx

  • 68 Carbine
  • Posts: 295
Re: Map Packaging Tool?
« Reply #2 on: October 29, 2014, 03:31:12 PM »
I got three questions about this.

1. How is paintball handling file extensions? In the tutorial map, the entitiy says paintball should load
"model" "models/props/keyboard/keyboard1.md2"
but there is no keyboard1.md2. Instead, paintball uses the keyboard1.skm model. Does it simply truncate the file ending and search for any model with that filename or how is that possible? I already noticed this behaviour at other locations, for example when giving filepaths to images where the entity says *.pcx and the file really is *.tga. Can anyone explain that? What happens if a .md2 and a .skm file (or a .pcx and a .tga file) exist? Which one is preferred? Should the tool accept these mismatching file extensions or should it throw an error?

2. How can i check whether a file is a r_script? I managed to extract the requiredfiles from the .bsp, but is there any way to check which of these files is a script except checking for location and file extension which may be faulty if the user put the script in the wrong place?

3. Should an .ent file be included if it exists?

Ace

  • Autococker
  • Posts: 661
Re: Map Packaging Tool?
« Reply #3 on: October 30, 2014, 06:20:04 PM »

xrichardx

  • 68 Carbine
  • Posts: 295
Re: Map Packaging Tool?
« Reply #4 on: October 30, 2014, 09:57:14 PM »
That's the site that helped me the most  :). Also very helpful:
models specification:
http://src.gnu-darwin.org/ports/games/warsow/work/source/skmviewer/skm_model.h
http://en.wikipedia.org/wiki/MD2_%28file_format%29

images/textures specification:
http://vip.sugovica.hu/Sardi/kepnezo/JPEG%20File%20Layout%20and%20Format.htm
http://www.fileformat.info/format/pcx/egff.htm
http://de.wikipedia.org/wiki/Targa_Image_File

I tried my best at writing all the algorithms needed to perform this. To easily get a simple GUI, wxWidgets is used, but this should be exchangable without much effort. I'll attach a zip containing source and an executable (wow, executables using wxWidgets are unbelievably huge). As I didn't have much time (neither beta maps on my computer) to test it, you should warned that it may make your computer explode or something like that. Tested with anubis, tutorial and spbup_kingdom_b3.

Of course, as always, any feedback is appreciated.

Edit: b2 attached.
-PNG support added
-support for mapshots in other formats than jpg added
-additional hr4 textures will now also added to the file.
-some minor things

Edit: b3 attached to later post.
« Last Edit: March 01, 2015, 05:02:43 AM by xrichardx »

jitspoe

  • Administrator
  • Autococker
  • Posts: 18801
Re: Map Packaging Tool?
« Reply #5 on: October 31, 2014, 03:53:38 PM »
1. skm is a replacement for md2, so the code is designed to just override md2 loads with skm+skp files, if available.  With images, the priority is png,jpg,tga,pcx/wal (I think).  The tool should match those priorities.
2. Check for "scripts/<mapname>.txt".  Also, "scripts/*" in the requiredfiles (in case it uses some sort of shared script).
3. If somebody is making a new map, they sohuldn't be using ent files, but I guess it could be useful for somebody trying to repackage maps... I wouldn't worry about it.

Thanks for working on this!  I'll try to check it out soon.

xrichardx

  • 68 Carbine
  • Posts: 295
Re: Map Packaging Tool?
« Reply #6 on: October 31, 2014, 11:09:26 PM »
Alright. I implemented your priority lists and ported everything to a pure WinAPI GUI. Project folder attached.

Edit: Simple icon and version information implemented. V4 should then be release-able unless someone finds any bugs.

Edit 2: minor things, performance optimization and a fix for the crash that happened in b4 when parsing a script with an empty line without a carriage return at the line ending.

Edit 3: More minor things, eg. handling for what happens if the user just closes the dialog where a file location should be selected

Edit 4: Sound files will be added.

Edit 5: Sound file path creation will respect existing file extensions

Edit 6: You can find the project page on github. Future changes and releases will be published there
« Last Edit: September 22, 2023, 06:31:15 AM by xrichardx »