This particular module had 2015 lines of code. I added nigh on 100 lines of comment. But after wrestling with the code for 2 days, its down to 1374 lines of code. Once I’d worked out what the code was trying to do overall, it was pretty obvious that most of what it was trying to do was redundant.
Because it was such a complex piece of code (for what it is) when I started, I figured that I’d get it finished tonight and spend tomorrow debugging it. But all it really does is manage the overall list of vehicles known to the game (British Rifle, British SMG … German Z34) and provides a couple of indexes to them, and a whole bunch of code for manipulating and verifying these lists.
typedef std::map<WEAPON_SPEC, WEAPON*> WEAPON_LIST;
BANG: 90 lines of code replaced.
Anyway – without all the frippery, its an incredibly simple subsystem, and I was kinda hard pressed to mess something up. It broke once because of an error thats been sitting in our datafiles for god knows how long that the old system didn’t pick up. Then it broke again when I forgot to update the same datafile on my client.
With everything seemingly up and running – I wasted a whole hour on discovering that my sound card drivers had crashed, or something. So, since the weapon stuff was working … I had time to nip into the client and add some alert dialogs for when the client can’t start up by some mundane problem.
If there was a really good reason why we didn’t do that, I’m sure Martini will explain it to me on Monday ;) I’m guessing Bloo will appreciate it ;)