Comment 27 for bug 977980

Revision history for this message
xxx-deleted (janosch-peters-deactivatedaccount) wrote :

I discovered that there is already a method used by the editor to check if a resource is allowed at a given point. As I only want to fix the bug and not change functionality, I re-used this method to do the resource verification on-load.

The old and new rule in Widelands is (see Map::is_resource_valid):

1. If the resource belongs to an impassable terrain (fish), there have to be at least two matching terrains adjacent.
2. For all other resources, there have to be 5 matching terrains adjacent.

If we simplify the rule to rule 1. for all resources, it will be possible to place minig resources on the border between mountain and grass. However, in those location it is typically not possible to build mines. So the player sees more resources but cannot use them. I think the best long-term solution would be to add an attribute in the resource configuration, which defines how many adjacent matching terrains are needed. This would lead to compact code and easy gameplay fine-tuning by just changing the configuration. But this should be done with a seperate bug report. Im eager to get the current fix into trunk.

TiborB's problematic map works now with the latest revision: The resources are removed because they have too few matching terrains nearby.

One problem remains: If changing a terrain leads to removed resources, they are not recreated when you undo the terrain change. I looked briefly into it, but it involves a lot of work and Im not sure if it is worth the effort.

I merged the trunk into the branch, hopefully the CI build works now. Please review the code again.