Utility to count screens in KS levels

  • 7 Replies
  • 3661 Views
*

Offline Vegetal Gibber

  • 686
  • 151
  • Sorry excuse for a game designer
    • View Profile
    • VG's Games Portfolio
Utility to count screens in KS levels
« on: January 08, 2016, 18:29:49 »
I cooked up this really simple, really badly coded program to help me count the number of screens in my levels. It's not exactly an elegant solution to the problem, but I thought it might be helpful to other authors, so I decided to release it here.

[ Download KSMapSize utility ]

To use it, just unpack the ZIP file to any folder you want, then drag'n'drop the Map.bin file of your KS level onto the "ksmapsize" executable (you can also create a desktop shortcut to the program and use that instead). A console window should pop up and tell you the number of screens in that level.

Obligatory disclaimer: This program is released "as is", be careful and use it under your own responsibilty, yada yada, blah blah, etcetera etcetera. You know the drill.
Some KS levels by me:

*

Offline Vegetal Gibber

  • 686
  • 151
  • Sorry excuse for a game designer
    • View Profile
    • VG's Games Portfolio
Re: Utility to count screens in KS levels
« Reply #1 on: February 22, 2016, 15:52:24 »
UPDATE! I found a strange issue with a few levels that causes this tool to report an incorrect (and really huge) number of screens on them. The best example of this is egomassive's Customnibus, which reports a whopping 7970 screens despite having only 4 filled rooms. Apparently, there's an undiscovered bug in the original KS level editor that causes some levels to have their Map.bin file filled with useless null data, which increases the uncompressed map file size by A LOT (about ~30MB in some cases!). If you use this tool on your own level and get an unexpectedly large number of screens (i.e, more than 1000 in a small level), it's very likely that your level is affected and has a big chunk of null data inside the Map.bin file.

This is basically harmless and won't prevent you from playing those levels and/or keep editing them, so you can just ignore it. Also, the GZ compression that KS uses for the Map.bin file pretty much cancels the increase in data size, which is why you don't end with a +30MB level folder and probably never notice this is happening internally. However, while this doesn't damage the actual level data in any way, some third party tools (like this screen-counting tool and KSLC) will report incorrect values and/or have trouble opening these levels. I'm thinking of updating this tool and including a simple check that will detect this error and ask you if you want to generate a fixed Map.bin file. I could also produce a standalone small tool just for that.

Edit: Just to be completely clear, this is not something caused by this tool :P2 If you get an incorrect (and absurdly high) number of screens when using the program on a level, it means the Map.bin file *already* had this issue from the start.
« Last Edit: February 22, 2016, 21:29:53 by Vegetal Gibber »
Some KS levels by me:

*

Offline sergiocornaga

  • 1247
  • 130
    • View Profile
    • Sergio's Games
Re: Utility to count screens in KS levels
« Reply #2 on: February 23, 2016, 03:10:45 »
I'm thinking of updating this tool and including a simple check that will detect this error and ask you if you want to generate a fixed Map.bin file. I could also produce a standalone small tool just for that.

I'm a big fan of destroying null data, so I'll look forward to this! Do you think it's something I could run on the entire Worlds folder to save a paltry amount of hard drive space?

*

Offline egomassive

  • 1703
  • 233
    • View Profile
    • egomassive games
Re: Utility to count screens in KS levels
« Reply #3 on: February 23, 2016, 10:43:20 »
I was curious to see if Level Composer could fix Customnibus. Once upon a time it salvaged a world that would no longer load correctly in KS or Loki's level editor. To my surprise, KSLC showed the huge room count, but otherwise didn't work with the level at all. On rare occasion I use KSLC to copy large sections of maps. If this tool can fix corrupted map files so they can once again work with KSLC, then it may prove useful one day.

*

Offline Vegetal Gibber

  • 686
  • 151
  • Sorry excuse for a game designer
    • View Profile
    • VG's Games Portfolio
Re: Utility to count screens in KS levels
« Reply #4 on: February 23, 2016, 16:30:23 »
@sergio: Well, since it's a command line program, I can make it so you can use it inside a FOR loop and process all the Map.bin files inside the Worlds folder recursively. However, you probably won't free any noticeable amount of drive space, because only a few levels are affected by this (so far, I've only seen this issue in some of ego's and farik's levels, and also in "Remembrance" by Si). Moreover, the Map.bin files are already compressed with GZIP, which pretty much nullifies the huge increase in size of the raw data (the garbage data is just a lot of 00 bytes, so the compression ratio is incredibly high). The only real benefits to fixing a bugged level are making it work properly with third party tools and a slight improvement on the loading times.

@egomassive: As a matter of fact, removing the garbage data from the affected levels does make them work again with KSLC :)  I can send you a fixed version of the level if you want.
« Last Edit: February 23, 2016, 16:32:04 by Vegetal Gibber »
Some KS levels by me:

*

Offline egomassive

  • 1703
  • 233
    • View Profile
    • egomassive games
Re: Utility to count screens in KS levels
« Reply #5 on: February 24, 2016, 05:44:16 »
I don't need to do any editing on my old levels. I was thinking of TToK. My temples in that game have full duplicate versions, so I use KSLC to make the copies. Though, if it became corrupted I could get a hex editor and clean it myself if I had to.

*

Offline SC

  • 116
  • 23
  • Ha-ha-ha! Videogames! *laugh track*
    • View Profile
    • My personal website!
Re: Utility to count screens in KS levels
« Reply #6 on: October 15, 2019, 20:37:06 »
Sorry for the necropost, but VG, have you ever made any work on the tool to fix the Map.bin files with null data in them?

*

Offline Vegetal Gibber

  • 686
  • 151
  • Sorry excuse for a game designer
    • View Profile
    • VG's Games Portfolio
Re: Utility to count screens in KS levels
« Reply #7 on: October 18, 2019, 18:16:16 »
No, I never added that feature since there seemed to be no demand for it and the impact of the filler data on KS' performance is pretty much negligible most of the time (you can shorten the initial loading time by about 1 second in some cases, but that's about it). However, you can do this yourself if you have a hex editor:


Alternatively, if you only want to fix a single specific level, PM me a link to it and I'll do it for you.
Some KS levels by me: