KS level designers and players are forever interested in the number of screens in a level. Counting the rooms is tedious and prone to error. So, I decided to figure out a clever way of doing it.
*
Warning* If you're not 100% confident in your computer skills, back up your level before proceeding.
Step 1: Decompress your map.bin file. It's found in your level's root folder.
DO NOT alter the original file or you may lose your level.
DO NOT re-compress the decompressed version. I use a free program called 7zip to do this. The resulting file is simply named "map" with no file extension.
Step 2: Find the number of bytes in the file. Megabytes and Kilobytes will not work. In Windows, right click and choose properties. Look for where it lists the file size in bytes. Ignore where it says size on disk. That's the wrong number.
Step 3: Subtract 10 then divide by 3020. Round off the answer and you have the number of screens on your map.
(x - 10)/3020 = y where x is the size of your decompressed map.bin in bytes and y is the number of rooms in your level. The most error I've found is around a thousandth of a screen. y +/- 0.001 = number of screens.
Step 4: Delete "map".
DO NOT delete map.bin.
I hope this helps. I know it sounds complicated, but it'll be a huge time saver over counting large levels. By the way, this info comes from looking at actual levels and their files. I have never look at the KS source. I don't have the compiler for it, so I don't look.
The way KS stores map data is by assigning a value to every location on the screen for every layer. If a screen is empty but part of the level, e.g. sky, then a null value is assigned to every location. Therefore, every screen takes up the same amount of space regardless of what's on it. However, KS automatically compresses it's map when storing it on disk. Now, how complex or simple a room is does make a difference.
By decompressing we ensure all the rooms are represented equally. Then it's simply a matter of dividing the total size be the size of a room, 3020 bytes. Except, every file has a header. That's the 10 bytes I have you subtract before dividing. The header probably varies in size from level to level and I'm sure it's where the error comes from.