Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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)

cav_speed.png (33.7 KB ) - added by elexis 9 years ago.
Technologies.js.patch (691 bytes ) - added by Michał 9 years ago.
patch fixing the issue
mods.jpg (397.5 KB ) - added by Michał 9 years ago.
proof of concept of the patch based on three cavalry unit 2-step modifications
0ad_comp.jpg (429.7 KB ) - added by Michał 9 years ago.
Comparison of current formatting and proposed .5s and .2f options for speed values.
0ad_comp2.jpg (159.4 KB ) - added by Michał 9 years ago.
Current formatting in comparison to formatting options .5s and .2f. Second option's impact in rounding value of speed
patch_2 (1.2 KB ) - added by Michał 9 years ago.
Second iteration patch.
3245.patch (1.2 KB ) - added by Stan 9 years ago.
This only display the two first number, so unless the speed is <10 || > 100 that should be fine
3245.2.patch (1.2 KB ) - added by Stan 9 years ago.
Proper Rounding

Download all attachments as: .zip

Change History (24)

by elexis, 9 years ago

Attachment: cav_speed.png added

comment:1 by elexis, 9 years ago

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!

by Michał, 9 years ago

Attachment: Technologies.js.patch added

patch fixing the issue

by Michał, 9 years ago

Attachment: mods.jpg added

proof of concept of the patch based on three cavalry unit 2-step modifications

comment:2 by Michał, 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 Michał, 9 years ago

Owner: set to Michał

comment:4 by leper, 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 

...

in reply to:  2 comment:5 by elexis, 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 Michał, 9 years ago

Attachment: 0ad_comp.jpg added

Comparison of current formatting and proposed .5s and .2f options for speed values.

by Michał, 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

by Michał, 9 years ago

Attachment: patch_2 added

Second iteration patch.

comment:6 by Michał, 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 leper, 9 years ago

We don't really have any floats in the gui. Just round it to the next int.

comment:8 by elexis, 9 years ago

The dog speed also needs a rounding iirc

comment:9 by Stan, 9 years ago

Any news ?

by Stan, 9 years ago

Attachment: 3245.patch added
This only display the two first number, so unless the speed is <10
> 100 that should be fine

comment:10 by Stan, 9 years ago

Keywords: review patch added

comment:11 by Stan, 9 years ago

Milestone: BacklogAlpha 19
Summary: Missing round for upgraded cavalry speed[PATCH] Missing round for upgraded cavalry speed

by Stan, 9 years ago

Attachment: 3245.2.patch added

Proper Rounding

comment:12 by Stan, 9 years ago

Owner: changed from Michał to Stan

comment:13 by elexis, 9 years ago

Keywords: simple removed
Summary: [PATCH] Missing round for upgraded cavalry speed[PATCH] Missing round for walk/run speed

comment:14 by elexis, 9 years ago

Component: Core engineUI & Simulation

comment:15 by Itms, 9 years ago

Resolution: fixed
Status: newclosed

In 17070:

Fix missing rounding in the GUI. Patch by stanislas69, fixes #3245.

comment:16 by Itms, 9 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.