…as I just had to discover while adding a new attack power for monsters to ADOM (related to the new domain of the Ice Queen but in the future also usable for other beings). I just noticed that killing a monster is handled inconsistently throughout the code.
The short version is that a lot of reactions can follow to killing a monster, from quests being fulfilled to alerts being raised to other monsters becoming hostile to various internal statistics being affected, etc. This gets more complicated by the fact that monsters can be killed either by the PC or other monsters (which may sound trivial but which it is not as the initial code did not consider monsters killing monsters and this stuff got tacked on later). In fact there now exist about half a dozen of methods handling the death of a monster, all in slightly different ways, sometimes calling each other in ways I no longer understand (or which are just wrong).
As the problems usually arise only in marginal cases (but maybe not always) it might be that nobody notices the effects. And we wouldn't be extending the game, it would not be a problem. But as I am extending the game right now, it is a problem - as I don't really understand the correct way to notify the game about the death of a monster anymore (due to the existing variants).
The consequence is simple: refactoring for unification. The actual execution is not, as 180.000+ lines of code need to be analyzed and who knows what kind of inconsistent results might occur. I guess that Prerelease 21 will be interesting in more than one respect. Sadly it will be very hard to roll back such a sweeping change if it causes major problems.
Oh well… Frankenstein also had peculiar problems with his resurrection approach… so why should this be different?
As a programmer longtime working with vast codebases, I feel your pain.ReplyDelete
However, usually such refactorings which result in simple, cleaner and ultimately shorter code leave me with a sense of satisfaction.
This comment has been removed by a blog administrator.ReplyDelete
Do you use version control (i.e. git/ github)?ReplyDelete
You may want to split refactors into small steps and possibly roll back/ re-review those if bugs occur.
Yes, we do. Subversion, not git. Personally I have to admit that I hate git for various reasons ;-)Delete
The problem however is the sweeping scope of the changes. Many hundred places will be touched.
And the lack of automated test cases.
Out of curiosity: Is there any roguelike game out there with extensive automated test cases?
off-topic: Are the 2 first comments from spam generators? If so, that's quite amazing imo.ReplyDelete
on-topic: fingers crossed ;)
I do, indeed, exist. ;)
I didn't have a chance to look at the second comment, so I cannot judge it, however, I thought my comment was on topic and not spam-like at all. ;)
@Leszek The first comment seems real. Spam usually has some underlying purpose like trying to redirect the reader to another website. The second appears to be a bot trying to re-write a random comment in different words using some sort of phrase thesaurus. As far as I can tell, the bot is targeting comments with keywords related to coding so that it can plug its virus-filled website who's only relation to computer graphics is the cg in the domain name. I admit that it's a good idea to re-write someone else's comment though. With a better thesaurus and a larger comment pool this spam could fool a lot of people.ReplyDelete