"Out of resources" messages should be triggered by productivity

Bug #1454371 reported by GunChleoc
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Undecided
Unassigned

Bug Description

Except for mines, "Out of Resources" messages are triggered by Worker::run_findobject for all production sites.

This is fine for quarries etc (basically, for buildings that have their delay_attempts = 0 in the conf. For other production sites, this is not as useful as it should be.

So, we should hook the triggering of this message into the site's productivity instead.

Related forum topic: https://wl.widelands.org/forum/topic/1733/

Tags: gameplay

Related branches

Revision history for this message
TiborB (tiborb95) wrote :

I would leave it as is but with one modification.

There is m_out_of_resource_delay_counter counter increased by 1 with each notify_player call (when resource is not found). It is zeroed only after publishing the message, when treshold (out_of_resource_delay_attempts, f.e. 10) is achieved.

For productionsites with non-renewable resources (stones, fish, undeground raw materials) - it is fine, but farmers, cutters have renewable/reappearable resources. So I suggest to just to zero the counter when a resource is found (unnotify_player() is called).

Should not have negative impact on mines and alike....

I am running some tests, it looks that is works as intended....

Revision history for this message
GunChleoc (gunchleoc) wrote :

Your suggestion will mean that for farms etc. the message would never be triggered, unless there is no room for fields at all.

Mines have their own code anyway and are not affected by this.

Revision history for this message
TiborB (tiborb95) wrote :

There is some strict mathematics behind this, but farms will get that message very rarely, f.e. if they are completely surrounded by obstacles.

Mines ARE affected by this, I set up some printf to test it...

Revision history for this message
TiborB (tiborb95) wrote :

or rather 'controlled by this code' I would say

Revision history for this message
GunChleoc (gunchleoc) wrote :

Mines have a completely separate code. Their "Out of resources" message is triggered within the productionsite/production program itself. The message itself is the same, but what causes the message to be sent is different. Check ActMine in the production program.

For the other productionsites, the trigger is the worker instead of the building. I think we should still keep this as the basic trigger, but instead of having a delay counter, we should check if the productivity is below a certain threshold and falling. If the productivity is low enough, the message will be sent. If not, no message. We can probably steal some code from the statistics strings here. For Quarries and Fishers, we could set this threshold to 100%, so the message gets sent out the first time the worker doesn't find anything.

When I implemented the message for farms etc about a year ago, my skills weren't good enough to make anything but this delay counter, which has never been optimal. Now I think I can do better :)

Revision history for this message
TiborB (tiborb95) wrote :

I was looking at Worker::run_findobject() function and ProductionSite::notify_player() subsequently.

I see our opinions (about solution) differs a bit so I am not going to work on it. Anyway, the problem is rather cosmetic then serious...

GunChleoc (gunchleoc)
Changed in widelands:
status: New → In Progress
assignee: nobody → GunChleoc (gunchleoc)
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have created a second branch that implements Tibor's suggestion. Let's discuss in the forum which solution we prefer.

Revision history for this message
TiborB (tiborb95) wrote :

fix pushed in revision 7479. Now the message is triggered if site's performance is below a treshold.

Changed in widelands:
status: In Progress → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → In Progress
milestone: none → build19-rc1
Revision history for this message
SirVer (sirver) wrote :

Fixed the regression test error related to this change in r7480.

Changed in widelands:
status: In Progress → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
assignee: GunChleoc (gunchleoc) → nobody
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

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.