Another update. I implemented all of Hirundo's suggestions and updated the code to trunk.v0.63:
Update to current trunk. Coding style corrected, including trailing whitespaces (I bet I'm missing something
). Statements to check current rating changed to a better solution that is already used in other parts of OpenTTD code. TownRatingColour implemented as a member of the Town class. Unified some duplicated code.
CommanderZ: I intend to do that, but only when I'm completely sure that I'm not missing something. I want to get this as good as I can
Hirundo: I followed your suggestions and inspected closely every line of the diff, and I think I got every coding style error. The first versions of the patch sticked to the colours in that enum, but I had to either include colours that broke the intuitive red-yellow-green progression (I tried blue, gold, silver...) or to use fewer colours and let half of the ratings sharing colours. Finally I decided to include more colours: I'm pretty sure that the results look good now, but I'm still not happy with the way I implemented it. Thank you for checking my patch!
SirXavius: Thank you, I hope you like it.
Here is an updated binary for windows. Since the behaviour of the patch hasn't been altered, the only "visible" change is the version bump.
Edit: Deleted, see the first post for an updated binary.