Since my last update I’ve done a lot of work on the game that isn’t all that visible to the gamer.
A month ago I was working on the trading post and was trying to build the dialog for user interaction. The user interface didn’t really having the tools I needed, and caused me to rewrite the code and add more features. When you start rewriting code, things tend to snowball….
First I added data derivation. This is a system where you can make a piece of data inherit all the properties of another, then change just a few things. A good example is the data the describes how a button in the user interface looks. When I go to add another button, it can inherit the properties from an existing one and then just change a few things, like the icon, text, or border. This can be done for any data in the game. This cuts down on typing and allows global changes quickly.
Next I rewrote the user interface code. It had a legecy XML input format from when I first started coding the engine. The parse code was annoying to modify when I added new data members. The new code uses the same data serialization as the rest of the game. It requires no extra code to parse. It only needs a simple serialization function for the data members which is also used for binary serialization.
I also added many new widgets to the UI system such as tabbed pages, sliders, clip regions, smooth scrolling, and new layout tools.
After the ui rewrite, the previous xml data that described all dialogs was unusable so I redid the artwork and layout of the entire interface. This took much much longer than expected but the results are very good. I can now skin the entire UI with a change to a single file and making a few new sprites.
Near the end of October I was traveling for a while and found that a touchpad on a laptop is a poor way to make art – both 2D and 3D – so I focused on some under the hood items that have been nagging at me for a while.
As a result, all binary resources and save games are now being compressed with a fast LZ implementation. This decreases load time on slow discs, and makes a smaller final package to distribute. The compression is about 50% of original size in most cases. Not bad.
The final thing I did was to write my own memory allocator. I’m not sure about other implementations on other systems but the MSVC2010 malloc() and free() are slow as turtles. I originally wrote it to speed up parsing of data files – this uses a lot of dynamic strings, maps, sets, etc, and it was taking multiple seconds to parse large data files with several layers of inheritance. With my new implementation I don’t even notice when text data recompiles to it’s corresponding binary format. As a bonus, the runtime allocations in the game also got faster and I got a surprising speed jump of performance by using my own allocator. That’s a win.