[1.1.27] simple-entity-* with render_to_forces stays selectable even if invisible.

Bugs that are actually features.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[1.1.27] simple-entity-* with render_to_forces stays selectable even if invisible.

Post by eradicator »

What?

A simple-entity-* that has been made invisible with i.e. render_to_forces = {'enemy'} can still be selected with the mouse cursor.

Expected behavior

Invisible things shouldn't be selectable. I'm 90% sure this was the case in some earlier version, 0.18 maybe?

Reproduction

Code: Select all

/c
local p = game.player
for i=1,3 do 
  for j = 1,3 do
    local x = p.surface.create_entity {
      name='simple-entity-with-force',
      position={p.position.x - 4 + 2*i, p.position.y - 6 + 2*j},
      force = game.forces[j]
      }
    x.render_to_forces = {game.forces[i]}
    end
  end
1) Use the code.
2) Move your mouse to select any of the nine entities above you.


Why?

Because I need certain things to be temporarily unselectable for everyone.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5246
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [1.1.27] Regression? simple-entity-* with render_to_forces stays selectable even if invisible.

Post by Klonan »

eradicator wrote:
Tue Apr 13, 2021 9:01 am
Invisible things shouldn't be selectable. I'm 90% sure this was the case in some earlier version, 0.18 maybe?
Are you sure? I can't see any changes in the related areas, can you point to a specific version where it works?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.27] Regression? simple-entity-* with render_to_forces stays selectable even if invisible.

Post by eradicator »

Klonan wrote:
Wed Apr 14, 2021 8:48 pm
eradicator wrote:
Tue Apr 13, 2021 9:01 am
I'm 90% sure
Are you sure?
According to my memory I once accidentially made an entity completely unselectible during runtime even though it still existed. Didn't need that back then so I don't have a demo mod. As far as my memory and the API doc goes render_player and render_to_forces are the only methods that come even close to doing that. But I just tried with 0.17.79 and 0.18.40 and the selection boxes don't disappear there either. And 0.16.x didn't have LuaEntity.render_* at all. So... I don't know what I did back then. Looking at the old code all I can see is that the type of the entity was "simple-entity-with-owner".

I guess that makes this NaB and I have to post it as an interface request?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5246
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: [1.1.27] Regression? simple-entity-* with render_to_forces stays selectable even if invisible.

Post by Klonan »

eradicator wrote:
Thu Apr 15, 2021 6:32 am
I guess that makes this NaB and I have to post it as an interface request?
I guess so :)

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.27] Regression? simple-entity-* with render_to_forces stays selectable even if invisible.

Post by eradicator »

Klonan wrote:
Thu Apr 15, 2021 7:58 am
eradicator wrote:
Thu Apr 15, 2021 6:32 am
I guess that makes this NaB and I have to post it as an interface request?
I guess so :)
Thanks for looking at it anyway, doesn't sound like a request with a particularly high chance of success though.

(Also it's a bit eery that you can apparently edit my posts without the forum marking them as edited. I said 90% because that leaves 10% chance that I'm wrong :geek: :mrgreen: .)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2856
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.27] simple-entity-* with render_to_forces stays selectable even if invisible.

Post by boskid »

Looking into code, render_to_forces on SimpleEntityWithOwner, SimpleEntityWithForce and FlyingText is used only by the rendering logic. Selection logic uses different check, "isVisible". In SimpleEntityWithForce it always returns isVisible()==true so it can always be selected. SimpleEntityWithOwner has this check a little more advanced: there is the SimpleEntityWithOwnerPrototype::force_visibility which changes the `isVisible` behavior causing entity to be possibly not selectable by other forces.

Given all the logic in the SimpleEntityWithOwner it looks that the split into selection and rendering may be intended: it will not render if any of the { shouldRender, isVisible } condition fails.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.27] simple-entity-* with render_to_forces stays selectable even if invisible.

Post by eradicator »

boskid wrote:
Thu Apr 15, 2021 8:37 am
SimpleEntityWithOwner has this check a little more advanced: there is the SimpleEntityWithOwnerPrototype::force_visibility which changes the `isVisible` behavior causing entity to be possibly not selectable by other forces.
That does seem to work on a new map. I'll have to try how far I can get with that.

However... if i try to load a save with the entity in it after adding force_visibility = "same" the game crashes.
Attachments
factorio-current.log
(22.04 KiB) Downloaded 148 times
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.27] simple-entity-* with render_to_forces stays selectable even if invisible.

Post by eradicator »

eradicator wrote:
Thu Apr 15, 2021 9:42 am
However... if i try to load a save with the entity in it after adding force_visibility = "same" the game crashes.
Hm... no, that doesn't seem to be the problem. Not sure what else I did to break that save though.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [1.1.27] simple-entity-* with render_to_forces stays selectable even if invisible.

Post by eradicator »

Looks like the crash only happens for one particular savegame + one mod. I'll upload them later unless someone tells me not to.

Edit: Reported 97882
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Not a bug”