#3245 closed defect (fixed)
[PATCH] Missing round for walk/run speed
Reported by: | elexis | Owned by: | Stan |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
When upgrading the cavarly speed at the corral two times by 10%, the walk speed of persian spear cavalry is not rounded properly, see screenshot attached.
Attachments (8)
Change History (24)
by , 9 years ago
Attachment: | cav_speed.png added |
---|
comment:1 by , 9 years ago
by , 9 years ago
proof of concept of the patch based on three cavalry unit 2-step modifications
follow-up: 5 comment:2 by , 9 years ago
Hi, I'm new here. Decided to contribute.
I think I've found where the error is. Please see attached patch.
Mainly, the modification to the value of the speed during the second upgrade was made based on the original value, that is:
No upgrades: 22, bonus on upgrade: 22*1.1 = 2.2 1st upgrade: 22 + 2.2 = 24.2 2nd upgrade: 24.2 + 2.2 = 26.4
I assume this is not what is wanted for this specific case.
So previously the multiplication bonus was made based on the original value. My patch changes this to apply based on the current, if a former modification was applied.
I have not the knowledge whether this is the expected calculation for every mod in the game - haven't read through the whole design unfortunately.
I can only imagine that there can exist a case where the additional bonus for a second tier upgrade would be based on the original value, not on the current. If that is the case, my patch does not cover it. Nor I think this both cases can be covered using modification.multiply - they would have to be separated, I presume.
Though, I'm no expert.
Waiting for any feedback on this.
comment:3 by , 9 years ago
Owner: | set to |
---|
comment:4 by , 9 years ago
Quoting the comment immediately preceding the code you changed
// Nothing is cumulative so that ordering doesn't matter as much as possible
...
comment:5 by , 9 years ago
Replying to kravvcu:
Hi, I'm new here. Decided to contribute.
Same here
Mainly, the modification to the value of the speed during the second upgrade was made based on the original value, that is:
No upgrades: 22, bonus on upgrade: 22*1.1 = 2.2 1st upgrade: 22 + 2.2 = 24.2 2nd upgrade: 24.2 + 2.2 = 26.4
The code you address in the patch proves that my computaiton in the first comment was wrong and this one above is correct. There is no rounding involved when computing the units moving speed. Both +10% speed increase upgrades refer to the original speed.
I assume this is not what is wanted for this specific case.
According to the comment it is, so that code change is not required.
What needs to be addressed is the tooltip itself that displays the computed value. It should round to max 3 or 4 decimal places.
Waiting for any feedback on this.
Thanks for working on this!
by , 9 years ago
Attachment: | 0ad_comp.jpg added |
---|
Comparison of current formatting and proposed .5s and .2f options for speed values.
by , 9 years ago
Attachment: | 0ad_comp2.jpg added |
---|
Current formatting in comparison to formatting options .5s and .2f. Second option's impact in rounding value of speed
comment:6 by , 9 years ago
I've found the part of code where the formatting is defined. Please see the attached files, I've included my propositions for the fix there, I think the .jpg's speek for themselves.
I assumed we would want at max 2 decimal places.
By going with the '.5s' formatting option we would assume exclusion of speeds over 100 - this would be formatted with only one decimal place as the formatting option is the maximum width of the formatted string (dot included).
We can format the speed value as a float by going with the '.2f' option which always shows two decimal places even if they're 0. The negative side is that the value is rounded to the nearest one, which is shown in the second .jpg. Even so, I included a patch with this options set, as I think determinism is what we want, when it comes to the number of decimal values shown.
Related attachments: 0ad_comp.jpg, 0ad_comp2.jpg, patch_2
comment:7 by , 9 years ago
We don't really have any floats in the gui. Just round it to the next int.
by , 9 years ago
Attachment: | 3245.patch added |
---|
> 100 that should be fine |
comment:10 by , 9 years ago
Keywords: | review patch added |
---|
comment:11 by , 9 years ago
Milestone: | Backlog → Alpha 19 |
---|---|
Summary: | Missing round for upgraded cavalry speed → [PATCH] Missing round for upgraded cavalry speed |
comment:12 by , 9 years ago
Owner: | changed from | to
---|
comment:13 by , 9 years ago
Keywords: | simple removed |
---|---|
Summary: | [PATCH] Missing round for upgraded cavalry speed → [PATCH] Missing round for walk/run speed |
comment:14 by , 9 years ago
Component: | Core engine → UI & Simulation |
---|
comment:16 by , 9 years ago
Keywords: | review removed |
---|
The walk speeds of those cav are:
No upgrades: 22 First upgrade: 24.2000...003 Both upgrades: 26.4000...003
Notice that 22 * 1,1 * 1,1 = 26,6 instead of 26,4 = round(22 * 1,1) * 1,1. So it looks like the upgraded values are rounded in general.
Thanks to ffm for reporting it!