Asynchronous saving and loading, and slightly more complex save files

I was planning on implementing doors yesterday, but I got sidetracked looking into the performance issues in infdev. While I’m not going to do major optimizations yet (but it is coming, for sure), I’ve pretty much realized that multi threading is definitely the road ahead. A lot of the stutters when moving around are caused by disk io (loading chunks, saving chunks), and doing that in a synchronous way means the game has to pause while waiting for the hard drive. That’s just plain bad design.

A few months ago, I did try doing some multithreading, but for some reason really slow computers ended up starving some of the threads, causing the terrain not to update at all, so this time around I’m going to have to add some synhronous “make sure it really has happened by now” method. I’m sure this is a solved problem already, so I’ll be googling for solutions.

Today, I’m adding doors and possibly other furniture. While finishing up the signs yesterday, I realized how incredibly convenient it was to have decorations as Entities (as opposed to blocks), something I already explored with the paintings. Making sure doors block player movement will require some additional coding, but that means that can animate nicely and have slightly fancier graphics than plain blocks do, and it solves the problem of them actually being larger than a single block. I’ll probably do chairs and other furniture the same way.

But this is a bit scary. Originally, I intended Entities to be non-essential parts of the game, so a level third party editor could just focus on the blocks and strip all entities, and the map would still stay the same (monsters would spawn to populate the map and so). But with increased focus on entities as actual long term game elements, level editors are going to have to become a lot more clever.

Actually, while writing this, I just realized (as in this very minute) that I should explore the TileEntity route I took for chests and furnaces instead!

I’ll go eat lunch, then get cracking on that. :D

Also, OK FINE, I will add ladders.

posted 13 years ago