Page 1 of 1

[0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Mon Nov 06, 2017 10:15 am
by Trainwreck
I'm seeing a strange issue with GotLag's Explosive Excavation mod. This mod allows placing of water tiles, and adds an on_player_built_tile event handler that creates explosions when a water tile is placed.

When this mod is installed, sometimes random explosions are spawned when placing landfill (not water).
Image
In these screenshots I had just clicked to place a large block of landfill. For some reason, factorio decided not to fill in the bottom row of the landfill brush. Apparently it still passed those coordinates to the on_player_built_tile handler, which, seeing water, spawned the explosions.

Since no landfill was placed in that bottom row, I would not expect the coordinates to be passed to the on_player_built_tile handler.

(I'd previously posted this bug in the Explosive Excavation forum thread here, reposting as a factorio bug report at authors request).

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Mon Nov 06, 2017 2:17 pm
by Loewchen
Generally the idea is that the mod author makes the bug report if he assumes an issue with factorio itself.

complete control.lua:

Code: Select all

function placedTiles(entity, positions)
  local surface = entity.surface
  for i,pos in pairs(positions) do
    if surface.get_tile(pos.x, pos.y).name == "water" then
      local victim = surface.create_entity({name = "fish", position = {pos.x+0.5, pos.y+0.5}})
      surface.create_entity({name = "blasting-projectile", force = entity.force, speed = 0, target = victim, position = victim.position})
      victim.destroy()
    end
  end
end

script.on_event(defines.events.on_player_built_tile, function(event)
  placedTiles(game.players[event.player_index], event.positions)
end)

script.on_event(defines.events.on_robot_built_tile, function(event)
  placedTiles(event.robot, event.positions)
end)

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Mon Nov 06, 2017 2:22 pm
by GotLag
It's a tile placement event triggered when the player is placing landfill tiles, but the set of positions returned apparently includes water tiles. I have not been able to reproduce it, but perhaps it depends on the geometry of the placed tiles.

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Mon Nov 06, 2017 7:06 pm
by Rseding91
I haven't looked into it but if I had to guess tile correction logic would be what I blame.

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Mon Nov 06, 2017 9:47 pm
by Trainwreck
GotLag wrote:It's a tile placement event triggered when the player is placing landfill tiles, but the set of positions returned apparently includes water tiles. I have not been able to reproduce it, but perhaps it depends on the geometry of the placed tiles.
I can reproduce it reliably, following the setup in the above screenshots exactly should work.
1. Place a large block of landfill at with one click. Don't run around holding the mouse button down.
2. Place the landfill over deep water.
3. Place the landfill south(down) from existing land.

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Tue Nov 07, 2017 3:55 am
by GotLag
You're right, successfully reproduced it. Triggers reliably in all directions except when building to the west (left), but even then it still shows up at the upper/lower edges of the player's buildable range.

For testing I disabled all mods that modify tiles or hook into on_player_built_tile except for Explosive Excavation, so I don't think it's any weird mod interaction.

Edit: to be really clear, this only occurs on deep water tiles - is this due to the correction logic enforcing the presence of water between deep water and grass?

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Tue Nov 07, 2017 10:26 am
by Rseding91
GotLag wrote:You're right, successfully reproduced it. Triggers reliably in all directions except when building to the west (left), but even then it still shows up at the upper/lower edges of the player's buildable range.

For testing I disabled all mods that modify tiles or hook into on_player_built_tile except for Explosive Excavation, so I don't think it's any weird mod interaction.

Edit: to be really clear, this only occurs on deep water tiles - is this due to the correction logic enforcing the presence of water between deep water and grass?
Most likely.

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Sun Nov 12, 2017 2:56 pm
by Klonan
So in essence, the tile correction is messing things up

Since we want to remove the tile correction, this will probably be fixed when its removed

Until then, it isn't a bug, as the code for tile correction is probably doing just exactly what it is meant to in the situation, and isn't worth investigating

Re: [0.15.37] Incomplete landfill placement,on_player_built_tiie

Posted: Sun Nov 12, 2017 2:59 pm
by GotLag
Fair enough, it's not exactly a pressing issue.