Return-To-The-Roots / s25client

Return To The Roots (Settlers II(R) Clone)
http://www.rttr.info
GNU General Public License v2.0
478 stars 77 forks source link

Tool order message too early #728

Closed Spikeone closed 6 years ago

Spikeone commented 7 years ago

When setting a ware in tool ordering, you get a message "the requested amount of tools has been produced" but this message is triggered before the metalworker even starts working. I may produce one tool, so I unstop the metalworker, wait till the requested number goes from 1 to 0 and stop it. The same moment the message is triggered. But sadly I then stop the metalworker before he started working, so I get no tool at all and am confused why I am still missing the tool although all indicators tell I should have one.

Flamefire commented 7 years ago

Will be fixing this. However we do have a bit of a race condition here and may want to change the behaviour. Imaging having 2 metalworks and an order for 2 different tools. At this point you want to see those 2 ordered tools in the order list. Now those 2 workers start producing and you expect that one produces the first ware and one the 2nd. Question: How should all this be displayed? Shall the ordered ware count be reduced immediately once they start producing or just when they finish? In the first case it may be a problem because the 2nd worker has to know, that the first is already producing the first tool.
2nd question: When should the completion message come? Once they finish their tool? Or when they start producing? Again first is tricky because at this point you might not know what happened in between. Or who should trigger the completed message? If the count is reduced both will see a tool order of 0 and will both send the message with is bad.

Easiest: Reduce the count once started and trigger the message there. Change: Metalworkers don't abort once started. Problem I see with reducing the count first is that it might be misleading. You expect the tool to be there already.

Harder: Introduce an "in production" count. Tools ordered are moved to "in production". This is removed once finished. If aborted we move it back. This solves both 1st cases from the 2 questions above.

Spikeone commented 7 years ago

Okay I'll just describe how I use the metalworker as this may be better in this case:

I order some or one tool. Now I have at least one time no '0' but a number.

Now my target is to stop the metalworker as soon as pissible so no iron is transported to the building.

There are two events which will make me stop the production: a) I notice no tools are ordered anymore, every number is '0' but production might not be done yet. b) I got the message that all ordered tools have been produced.

I do not really care when the numbers are substracted, I only need to know any tool is produced if all ordered numbers are '0' and the building is not destroyed.

So regarding your problems it should be fine to decrease the number when production ends.

Without toolordering I only set 1 Tool to 100%, set an observation window on the building and counted work cycles.

Hope this helps :D

Flamefire commented 7 years ago

Fixed it like this: Metalworker will check if he could produce anything. If yes, he will go into first waiting state. During this state production (in all types of buildings) can still be cancelled and no wares would be used. Before he really starts working we commit the order and use the wares if there still is an order. If not, we wait till next order is placed.

This is also applied to mines which had a similar bug: Stopping a mine in the wait state will make you loose a resource from the mountain.

Only downside: Having multiple metalworks and placing 1 order will make all of them start waiting-work, but all but one will cancel once their wait-state has finished. I find this very minor, so this is ok.

Spikeone commented 7 years ago

Agreed, it doesn't happen that often that someone uses more than on metalworks, orders one tool and unpauses both