Server Outage

The server that has been hosting my blog, my email and the Eressea server for the past ten years is no longer. It’s not a case of machine failure (those are easy to ix), but a policy change. One that I fully understand.

My options at the moment are to either get my domains hosted someplace else (some kind of root server) or to diversify to different providers. My mail is already mostly taken care of by Google, my blogging can move, and the Eressea server is currently running under my desk with very sporadic uptime.

That latest one is a temporary solution at best. I don’t have a machine that’s permanently on, the DSL line gets clogged on Sundays, and on weekends where I’m away, everything stops.

Running your own blog software means you are either a dinosaur or an A-List blogger. I’m certainly not the latter, so it’s time to move on. What pains me most is that this means breaking all the old URLs until I find a way to redirect enno.homeunix.net in a smart way.

Eressea Server Down

The Eressea server (and with it, this blog) has been down for about a week due to a burnt motherboard. The hard drives could be saved, but the new machine doesn’t have SCSI, so some work had to be done. Thanks go to Andreas and Nils for fixing this.

The new machine is no longer Debian but Ubuntu. This gives me a chance to set things up The Right Way – after 8 years, the old machines had a lot of quirky stuff installed, and was running with a number of unexplained anachronisms. So excuse the mess, we’re under construction.

Here’s my preliminary TODO-List:
Continue reading

Adventures in Optimization

This weekend I thought it would be a good idea to run the Eressea server both with and without optimizations enabled and compare the output. In theory, I thought, optimization should not change the results, and different results would hint at bugs like uninitialized variables or illegal memory access.

Needless to say, the output wasn’t the same. It was slightly different, and it looked like a small error snowballing towards the end. I’ll spare you the tale of a day trying to narrow down the exact location, and cut right to the chase:
Continue reading

Eressea: text vs. binary data files

I’m posting about this because I like talking about code and nobody is on IRC. If you don’t like code, you may want to skip this. Also, none of this is rocket science, but it was a nice exercise.

Traditionally, the data files in Eressea have been text files. You know the kind where you’re doing a lot of fprintf and fscanf everywhere in the code. There are usually two advantages associated with that: small integers take up less space (2-3 bytes instead of 4), and when something goes terribly wrong, you can edit the data with vi.

The latter had long been a mixed blessing, with edits occasionally doing more harm than good, and since the introduction of a shell and script access to all the game data, it’s not really been necessary. Which left three reasons not to switch: Slight space improvements, the amount of work to change over to something else, and backward compatibility. However, I had some time on my hands recently and decided to tackle all of those issues.
Continue reading

Eclipse + CDT + MinGW + XP x64

I’ve previously complained about the lack of decent free IDEs for developing C++, and since it’s been a while, I gave Eclipse another shot. The good news: CDT 4 no longer crashes every 5 minutes, it has much better project structure, and I think I can work with this. The bad news: It took ages to get everything up and running with MinGW.

The following is an attempt to remember what the problems were.
Continue reading

Optimization potential

The battle in Partôr during week 510 provides an excellent opportunity to do some profiling on Eressea. The whole turn took at least twice as long as usual, and gprof blames a single function for it. I knew this function was bad. The problem is, it really needs to be called this much.

I looked really hard at the usage pattern for the function this morning, and I think I can build a small cache with some information and reuse it for subsequent calls. Anyone dying in the battle invalidates the cache, but still, I figure I might be able to save some 75% of the actual work. Man, I’ve looked at this one at least twice in the past and never seen this!

[Listening to: Battle 22 – Ugress]

Continue reading

Speed!

Yesterday I checked out a 3 year old version of Eressea and compared it to today’s code. In those three years, the game has gotten almost four times faster! The old code took 10:20 minutes to run a turn, and the one I use today was done after 2:50. This had to be done on an old data file, smaller than the one we have today.

I knew I had been doing the occasional optimization – run the code with gprof, fix the worst offenders, rinse and repeat – but I had no idea the gains were that big. I’m sure that 3 years ago I considered the code pretty compact and fast…

I wonder what it will be like in three years.

[ media | Creedance Clearwater Revival – Fortunate Son ]

Making Wrong Code Look Wrong

Here’s a very good article by Joel Spolsky that you should read. It talks about why hungarian notation is a Good Thing, and how almost everyone uses it in a Bad Way.

I was rewriting the recruiting-rules for Eressea last weekend, and the rule there is that “for each peasant in a hex, players can recruit one person, except orcs, which can recruit 2 orcs per peasant, up to a limit of peasants/20, and if players want to recruit more, then the peasants in the hex are distributed evenly”.

The codes ends up looking a bit like when you’re trying to split your bills and you’ve been paying with 3 different currencies… I had a bug in that code, and only found it after I prefixed all my variables with p for numbers that represented peasants, o for numbers that represented orcs and d for numbers that represented the demand of a player – suddenly you see that you assign between them without the proper conversion.