[posila] [2.0.14] util.combine_icons() incorrect scaling

This subforum contains all the issues which we already resolved.
User avatar
rycieos
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Feb 27, 2019 8:35 pm
Contact:

[posila] [2.0.14] util.combine_icons() incorrect scaling

Post by rycieos »

I think this worked correctly in all versions of 1.1 I tested, but 2.0.7 and 2.0.14 has it broken.

data/core/lualib/util.lua has the following function:

Code: Select all

function util.combine_icons(icons1, icons2, inputs, default_icon_size)
and has this line:

Code: Select all

icon.scale = scale * ((icon_to_add.scale or 32.0) / icon.icon_size)
This incorrect logic, as using this ends up with scale values like 0.0000124, which obviously will fail to render the icon.

The correct line should be

Code: Select all

icon.scale = scale * (icon_to_add.scale or (32.0 / icon.icon_size))
User avatar
rycieos
Burner Inserter
Burner Inserter
Posts: 7
Joined: Wed Feb 27, 2019 8:35 pm
Contact:

Re: [2.0.14] util.combine_icons() incorrect scaling

Post by rycieos »

Confirmed this was broken in 2.0.7, see the changelog here:
https://github.com/wube/factorio-data/c ... 574c0bR357

According to Lua order of operations, `/` is before `or`, so this effectively changed from

Code: Select all

icon.scale = scale * (icon_to_add.scale or (32.0 / icon.icon_size))
to

Code: Select all

icon.scale = scale * ((icon_to_add.scale or 32.0) / icon.icon_size)
posila
Factorio Staff
Factorio Staff
Posts: 5438
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [posila] [2.0.14] util.combine_icons() incorrect scaling

Post by posila »

Thanks for the report.
Fixed for 2.0.33

I was not aware we have this function, so at first I wanted to improve it to be more in-line with how 2.0 interprets icon definitions and how it renders them (in GUI - it tries to shift and scale it, so that entire icon fits the slot, not just the first layer and without regard to shifting), but I am not sure how this functions should work exactly, so I gave up on that and just fixed the reported bug.
Post Reply

Return to “Resolved Problems and Bugs”