[devlog] Stability Fix

rtitle05Hey !

It’s going to be a very short but very important devlog. I spent the last week fixing the stability issues people were experiencing with Unending Galaxy. The main reason why the game wasn’t stable in the first place was because it’s fully multi-threaded (able to use all your CPU power) and because I wasn’t able to make it work 100% of the time until now. Before labeling me as an incompetent coder please look at the CPU usage of your favorite AAA games, yeah not so good either, hey :). Multithreading is hard to get it right, and the more complex your game is, the harder it is. Anyway, after a whole week of debugging, I finally managed to make it work properly. It took its toll on the performances and nearly nullified the benefits of last week‘s improvements, but it was worth it. I’ve been looking at the same game for hours and hours trying to make it crash and it simply doesn’t. More to the point, there’s tons of “please don’t crash” code that I can safely remove now, which should in theory improve performances again.

As a general note and because I know there’s other coders reading this article, it’s tempting to ignore multi-threading issues at first, and most of the time you can get away with it through try..except blocks, at least for a while. Do not do that, ever. You’ll end up with weirder and weirder things to debug, exceptions making no sense, and you’ll dig through, add special cases, and it will never end.. Make it thread safe from the beginning, and you’ll avoid all that. Contrary to popular belief amongst programmers, critical sections and all that jazz won’t kill your performances, yes it’s costly, but comparatively to whatever custom answer you’ll find, it’s 100% more secure and faster, period. (also, since windows vista, it’s possible to lock your memory for writing operations while keeping reading free for all your threads, and the cost is negligible at best).

Anyway, you’re not a coder or you don’t care, so let’s get back to Unending Galaxy proper. This week was a bug fixing week. I know it seems boring but that was the most important step in this game’s development process ever. Firstly because I can now stop worrying so much about people not being able to enjoy the game and secondly because I can focus on new features instead of additional bogus bug fixes.

I added a ridiculously large map to the deluxe edition (>1100 sectors). Same as with the Imperium map, while the game has no fixed plot, the layout draws the story. Each faction starts with it’s own territory far away from the main map which is covered by the Swarm. Factions can’t invade each other initial (and limited) territory, but the main map is a free for all granted they can manage to deal with the Swarm. If the player want to start as a faction, he gets the same opportunities as the others. The map isn’t symmetrical, but it’s balanced enough to play multiple games and get very different results.

Also, while trying to fix the multi-threading related crashes, I fixed multiple silent bugs. I won’t list them all but here are the most important ones: In some cases automated/AI ships would ignore friend/foes when deciding what to do. For instance, they could try to buy escort ships in hostile territory, dock traders would try to dock at neutral/friendly stations in hostile territory, pirate raiders would suicide themselves in hostile territories, space-fly hunters would not care for hostile sectors / factions when looking for a target and so on. All of this is fixed.

I said beta 4.1 was the last beta version. But given those last minute improvements, I think it would be safer to launch a last beta (so, beta 5) just to make sure my fixes are working for everyone. We’ll see about that in a few days 🙂