Fish breeder can't breed fish if the game is loaded after all fish is caught

Bug #1749586 reported by Evgeny Kapun
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Medium
Unassigned

Bug Description

How to reproduce:
* Start a new game for Atlanteans.
* Build a fisherman's house somewhere near water.
* Wait for the fisherman to catch all the fish he can.
* Save the game, end the game, then load the just saved game.
* Build a fish breeder's house next to the fisherman's house.

Expected result:
The fish breeder should begin breeding fish, and the fisherman should start catching it. This is what happens if the saving/loading step is omitted.

Actual result:
Both the fish breeder and the fisherman complain that they can't find any resource, and they don't work.

I think that this bug is caused by this piece of code [1]. When loading a game, it checks whether the amount of a resource is zero, and in this case sets its id and start_amount to zero as well. I think that this check is unnecessary and harmful, and should be removed completely. In any case, saving and then loading a game shouldn't change its behavior.

[1] https://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/map_io/map_resources_packet.cc#L66

Tags: savegame

Related branches

Revision history for this message
TiborB (tiborb95) wrote :

Is this not an expected behavior? Fish breeder needs at least some fish on the field to breed additional fish.
Whether they complain or not is secondary. Are you sure that fish breeder breeds any fish before game save?

Revision history for this message
TiborB (tiborb95) wrote :

... but on the other side, I am not sure what is benefit of setting the start_amount to 0 in linked code...

Revision history for this message
Evgeny Kapun (abacabadabacaba) wrote :

If this is intended behavior, it should be the same whether you save/load the game or not. Also, it is not intuitive: in real life, a fish breeder would be able to bring some fish from one place to the other.
Also, fish breeder's animation shows him just releasing a fish. Why would he need some other fish to be there already to do it?

Revision history for this message
TiborB (tiborb95) wrote :

Yes, the behaviour should be the same, therefore I was asking if you are sure a fish breeder ever breed a fish on field where there were 0 fish before...

Yes, it might not be logical, but still should be consistent...

Revision history for this message
Evgeny Kapun (abacabadabacaba) wrote :

Yes, a fish breeder can breed fish, if there were some fish there initially (when the game started, or, due to this bug, when it was last loaded). If there never were any fish on a field, then a fish breeder cannot breed fish there. I think that this is the correct behavior. It's not good if you can make water permanently unusable for fishing, by catching all fish there (this applies to Atlanteans, as other tribes have different sources of renewable meat supply).

In the code, there are no checks that would prevent a fish breeder from breeding on a field where current amount is zero. This code [1] only checks that the current amount of a resource is less than the initial amount, and this code [2] does the same checks.

[1] https://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/logic/findnode.cc#L113
[2] https://bazaar.launchpad.net/~widelands-dev/widelands/trunk/view/head:/src/logic/map_objects/tribes/worker.cc#L209

Revision history for this message
TiborB (tiborb95) wrote :

You seems to be right, I am surprised. Perhaps there is something else we are overlooking.

Are you interested to do actual coding and contributions to the game?

Changed in widelands:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → build20-rc1
Revision history for this message
GunChleoc (gunchleoc) wrote :

I agree that that code can go - I see no reason for it. We also need to fix the corresponding save function, and make sure that older savegames with depleted resources will still load properly.

tags: added: savegame
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Here is a savegame from bzr8593[trunk].
Started as network game, Last Bastion, no Opponentn, open gane.
After running with 65x for some minutes the fisher complained
"no fish". checking with the debug view I found "Resource fish 0/20"
at the coastline.

Sidenote Fishers can only fish at the coastline,
all the other fish will not be caught.

I played this as Atlatenr, but on load I found myself to be a barbarian?

Anyway: the debugview now shows "Resource none".

Next try with the bugfix branch.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Played the same with the new version, found that Fishbreeders can work again
and Debuggig shows recovery of fish resources.

GunChleoc (gunchleoc)
Changed in widelands:
status: Confirmed → Fix Committed
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.