Latest Posts

Topic: minor bug with deleting

Speter
Avatar
Topic Opener
Joined: 2017-11-22, 07:09
Posts: 19
Ranking
Pry about Widelands
Location: Australia
Posted at: 2018-02-21, 07:44

I noticed a bug while deleting some water in a map. Minerals and fish were also deleted.

Before deleting the water:

After deleting the water:

I don't think this is a big issue, but thought I'd mention it. face-smile.png


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2434
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2018-02-21, 08:17

Checked it and this happens also when removing other resources, e.g. removing coal removes also water.

Wrote a bug report. Which widelands version are you running?

Thanks for reporting face-smile.png

Edited: 2018-02-21, 08:44

Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
Speter
Avatar
Topic Opener
Joined: 2017-11-22, 07:09
Posts: 19
Ranking
Pry about Widelands
Location: Australia
Posted at: 2018-02-21, 11:47

I am running build 19.


Top Quote
Solstice_s_Return
Avatar
Joined: 2020-01-28, 13:24
Posts: 62
Ranking
Likes to be here
Location: Finland
Posted at: 2020-02-04, 08:50

Contrary to this finding, I found that bug helpful when I did fine tuning of my last map. So I didn't consider it a bug.


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2020-02-07, 09:57

The bug report is now at https://github.com/widelands/widelands/issues/3174


Busy indexing nil values

Top Quote
knarf
Avatar
Joined: 2024-01-03, 21:20
Posts: 45
OS: Debian
Ranking
Pry about Widelands
Posted at: 2024-01-14, 23:39

Trying to look into it I noticed a few things. Please correct me if I am wrong: I am new to the code:

  1. Each field can only have one resource. This seems to be true for all resources, so you can only have water OR fish (which by itself sounds a bit strange).
  2. Fields on the coast can in principle hold water and fish, but because of 1., it is actually water or fish.
  3. editor/tools/set_resources_tool.cc calls map->initialize_resources(mr.location(), args->current_resource, amount); with the currently selected resource
  4. What 3. does is

    • set the resource type of that field to the new type
    • set the amounts to the wanted amount

    So, in the end, this does not only remove the currently selected resource, but it also changes the resource type to the currently selected one (if valid on that field).

Whether this is a bug or a feature is now largely a matter of expectations. Consider a field which currently holds resource A, but could also hold resource B instead. Now you tell the editor to set the amount of resource B on that field to some non-zero value. You could

  1. go ahead: remove resource A and set B accordingly, or
  2. ignore, as resource A is already set

Here, I tend towards 1.

Now consider the same situation, but you tell the editor to set the amount of resource B to 0. Again, you could

  1. go ahead: remove resource A and set B to 0, or
  2. ignore, as there is already nothing of resource B on that field.

Here, I tend towards 2 (but the editor seems to do 1.)

What we could (and in my opinion, should) do, is to make sure that setting resource B to 0 does not affect resource A if B is already at 0 (resource A is currently set).

I am not sure if this solves the described problem, but it seems to me that it does, and it might be not so difficult to implement (but I have not tried). What do you think?

Edited: 2024-01-14, 23:42

Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2434
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-01-15, 11:14

One can expect that a node can hold both water and fish. But what about other resources like coal and iron? I think no one would expect that a node can hold iron and coal (plus gold?) simultaneously. Placing resources is likely done with a bigger toolsize so each click applies resources to many nodes. If a node can hold more than one resource there will be overlapping areas containing coal and iron on one node. And which resource should a geologist find then?

Additionally some terrains "contain" water or fish with a default amount, so placing such a terrain means there is already water or fish. One can't see this though, it is also currently not possible to get those amounts without using some lua code (or digging through the source code). Placing water and fish is therefor mostly useless, except you want more than the default amount of this resource being available.


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2024-01-15, 11:21

regarding water and fish. from a ressources point of view water means Ground water (for building wells).


Top Quote
knarf
Avatar
Joined: 2024-01-03, 21:20
Posts: 45
OS: Debian
Ranking
Pry about Widelands
Posted at: 2024-01-15, 21:20

kaputtnik wrote:

One can expect that a node can hold both water and fish. But what about other resources like coal and iron? I think no one would expect that a node can hold iron and coal (plus gold?) simultaneously.

Why not? I wondered whether that is the case, actually. There is not really a logical reason why a mountain could not contain both. Whether this is intended would be up to the map maker. But this argument is mood anyway if, as I still read the code, a field can only contain one resource. Btw: is the latter true: does the code only support one resource type per node?

If a node can hold more than one resource there will be overlapping areas containing coal and iron on one node. And which resource should a geologist find then?

There are a few possibilities. It could be a random one, with probability based on the actual amount. Or it could be the one with the maximum amount (and random or something else for ties). It wouldn't be that unreasonable.

One can't see this though, it is also currently not possible to get those amounts without using some lua code (or digging through the source code).

I didn't know. Is there a reason? Without thinking hard about it, this does sound like a bug to me. Wouldn't I want to see all that info in the editor?

Placing water and fish is therefor mostly useless, except you want more than the default amount of this resource being available.

What if I want the opposite: how do I remove resources from the default amounts if I don't see them in the first place?

But to come back to the original problem of this thread: here, removing one resource seems to remove another, which sounds like something that is not wanted and which we could improve upon.


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2434
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2024-01-16, 12:10

knarf wrote:

kaputtnik wrote:

One can expect that a node can hold both water and fish. But what about other resources like coal and iron? I think no one would expect that a node can hold iron and coal (plus gold?) simultaneously.

Why not? I wondered whether that is the case, actually. There is not really a logical reason why a mountain could not contain both.

Sorry, real world explanation: The genesis of coal is totally different from the genesis of iron, gold, or stone. If you hear something about a mine you will ever hear "The coal mine, the iron mine, the gold mine, the diamond mine" So from a human perspective there are only mines of one type. Yeah, widelands is not the real world, but it should not be too different, imho.

What if I want the opposite: how do I remove resources from the default amounts if I don't see them in the first place?

You might want to read this discussion

But to come back to the original problem of this thread: here, removing one resource seems to remove another, which sounds like something that is not wanted and which we could improve upon.

Yes, definitely. Maybe there can be some rule, e.g.

  • "If a node where one adjacent field is water terrain, prevent placing water here.", this keeps fish
  • "If a node where one adjacent field is mountain terrain prevent placing water here", keeps mountain resources

So water can't be placed directly at the border of water terrains and can't be placed at the border of mountain terrains. I think this would not change any game mechanics and would not have an effect on game play.


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote