Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production procedure aborting #923

Closed
vaut opened this issue Jun 15, 2020 · 2 comments · Fixed by #953 or #990
Closed

Production procedure aborting #923

vaut opened this issue Jun 15, 2020 · 2 comments · Fixed by #953 or #990
Labels
Milestone

Comments

@vaut
Copy link
Contributor

vaut commented Jun 15, 2020

Describe the bug
Loss of energy when replacing a unit in a production line.

To Reproduce
The situation: you added two different units to the factory production list. When the first one's production process is finished, the second one's production process will be started. But during the production of the first unit you've decided to cancel the first unit but to keep on production of the second one (in case your first unit is useless in current circumstances of your game). There are two ways how to reorganize your production.
The first one is a quite long: you abort the whole production by double right-click on factory's icon and add the second unit to the production order, getting back all power you invested in the production of the first unit. Total clicks: 3, energy losses: 0
The second way is shorter: you just reduce the number of first unit in your factory's order, so it start to produce the second one immediately. Total clicks: 1. But there we have the problem. All power you invested in the first unit's production is being lost due the second way. It can be easily spotted especially if you like playing high-oil games using the infinity production cycle.

Expected behavior
Energy is returned regardless of the method of canceling production. Perhaps even from the demolition of the plant.
Or vice versa never returns.

Screenshots or Videos
save power https://youtu.be/Dkrlbp_pRKQ
lost power https://youtu.be/_Vy4C29zkeo

Your System:

  • Game version: 3.3.0
@vaut vaut added the Bug label Jun 15, 2020
Colin-Mac-Donald added a commit to Colin-Mac-Donald/warzone2100 that referenced this issue Jun 22, 2020
Fixes Warzone2100#923

When stopping the current production of a unit by right-clicking on that unit and reducing the number required to zero, we do have a test for that, which erases the active production run.  However, it doesn't go through cancelProduction() and don't refund the spent power.

I've factored out the code from cancelProduction() that refunds the power if production is actually in progress (build points remaining are less than the total required) and am calling that from the existing test to cancel the current production when the number required equals zero.

Something to note is the last unit of power refunded can take several seconds to appear, making it look as though there's an off-by-one in the refund, but it eventually settles down at the original amount.
@Colin-Mac-Donald
Copy link
Contributor

Thanks for another great bug report, vaut. It's an absolute pleasure to work on such clear and specific issues.

@vaut
Copy link
Contributor Author

vaut commented Jun 22, 2020

It was not me who discovered and described the problem.
Everything except the video was prepared by Fedaykin.

past-due pushed a commit that referenced this issue Jun 22, 2020
Fixes #923

When stopping the current production of a unit by right-clicking on that unit and reducing the number required to zero, we do have a test for that, which erases the active production run.  However, it doesn't go through cancelProduction() and don't refund the spent power.

I've factored out the code from cancelProduction() that refunds the power if production is actually in progress (build points remaining are less than the total required) and am calling that from the existing test to cancel the current production when the number required equals zero.

Something to note is the last unit of power refunded can take several seconds to appear, making it look as though there's an off-by-one in the refund, but it eventually settles down at the original amount.
past-due added a commit that referenced this issue Jun 24, 2020
past-due added a commit that referenced this issue Jun 24, 2020
past-due added a commit that referenced this issue Jun 25, 2020
@past-due past-due reopened this Jun 25, 2020
Cyp added a commit to Cyp/warzone2100 that referenced this issue Jun 29, 2020
If having queued two different templates, and right-clicking the currently-building
one so it reaches 0, then the new template would be started without refunding the
current one.

Based on Warzone2100#923 2e1711f.
KJeff01 pushed a commit that referenced this issue Jul 2, 2020
If having queued two different templates, and right-clicking the currently-building
one so it reaches 0, then the new template would be started without refunding the
current one.

Based on #923 2e1711f.
@KJeff01 KJeff01 added this to the 3.4.1 milestone Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants