Code duplication squared
NetHack’s code quality isn’t of varying quality. Gradually one gets used to the different style of coding that pervades NetHack’s source code that is almost inevitable on code that has seen dozens of programmers over more than twenty years.
But sometimes, I still get surprised by the pearls of code that can be found in NetHack.
What’s really funny about this is the comment in the middle of that code: “Okay, _you_ write this without repeating the code“.
Although that comment really is referring to the fact that this code – that deals with monsters resp. the player reading a scroll of earth – is made up of two quite similar parts, one for the player and for monsters.