Emergency 4 is a game that I spent a lot of time in, unfortunately I started playing this game back in the day when it was not available on Steam, but Steam shows 54 hours and the amount of hours spent outside of Steam is probably in the 1500 hour range.

In recent years however, this game has become basically unplayable in Freeplay mode. In Freeplay mode you are basically an emergency dispatcher, and you need to direct emergency services to different types of callouts while also maintaining the peace and normal flow of life in the city you have control over.

So why has this game become unplayable? Well, that's simply because our computers are now too powerful, and the game's clock is attached to the framerate oof. You see, these days games mostly utilize something called a delta time to step perform operations such as movement, AI and world logic. A delta time also allows for easy control over the game's speed. If you want the game to stop, you simply stop incrementing the delta time, if you want the game to slow down you start decreasing the rate the delta time increments.

Emergency 4 does use some sort of delta time in some places, however not for traffic lights and several other calculations. This sucks. Because this has as a result that it's a matter of time before your city enters a gridlock because the vehicle AI is not bound to the framerate. In example, a car approaches an intersection and gets the greenlight for a second, and then the traffic light quickly jumps to red again.

Some modificiations of the game solve this by going through every traffic light and increasing the "jump" time to an obscene number. I'll have none of that, thanks.

So I have set out to create a game with a similar premise, however building upon a platform that allows backwards compatibility to Emergency 4 and 3 files. This still allows me to visit my favorite modifications such as the Los Angeles modification.

Hostage situation in the Los Angeles modification

First steps

So I have started work on Responders Project (website pending) to create this game. First however I needed to sort a few things out.

I need test assets, and my modelling skills are not very favorable... so my assets of choice are Emergency 4 assets. This would be an easy case of simply building a V3O mesh loader and using a mesh abstraction layer to allow later loading of modern formats such as FBX and Collada.

This poses a problem however, you see Emergency 4 was built in a time when disk space was important. A game could simply not get away with being 80GB in size, that was in fact the size of my entire hard disk when I started playing this game. No, Emergency 4 is 1.9GB and it achieves this by "packing" all assets. This basically means compressing the assets to reduce it's size and also increase loading times by decreasing the file read overhead.

Luckily, I've managed to tackle this issue! As it turns out, Emergency 4 packs it's files with a semi-custom ZIP format. Basically a packed file looks a bit like this:

  • 20 header bytes
  • compressed ZIP data, in chunks of 1024 bytes

So I've come up with this little bit of hastily written code to test this:

public bool ReadPacked(string filename)
    FileStream inputStream = new FileStream(filename, FileMode.Open);
    InflaterInputStream inflaterStream = new InflaterInputStream(inputStream);
    MemoryStream memoryStream = new MemoryStream();


    byte[] buffer = new byte[1024];

        int read;
        while ((read = inflaterStream.Read(buffer, 0, buffer.Length)) > 0)
            memoryStream.Write(buffer, 0, read);
    } catch (Exception e)
		// Something? TODO!

    _contents = memoryStream.ToArray();

    return true;

This code has just one dependency: SharpZipLib for ZIP decompression, aint nobody got time for implementing a ZIP inflator.

This basically transfers the decompressed bytes into a byte array and when you convert this to a string you get the raw model, prototype or map data.

That's basically all for this blog post, hopefully until next time with some more exciting updates!

For now I'll leave you with the trailer for Emergency 4 Deluxe edition.