[2.0.60] Game freezes when teleporting player to non colliding position

We are aware of them, but do not have solutions that don't cause other issues. They go here in order not to take space in the main bug thread list.
DeadMG
Fast Inserter
Fast Inserter
Posts: 102
Joined: Thu Oct 22, 2020 7:56 am
Contact:

[2.0.60] Game freezes when teleporting player to non colliding position

Post by DeadMG »

What did you do?
I'm making a Warptorio-style mod where the player can teleport between surfaces. I've used surface.find_non_colliding_position to decide where to place the player and using player.teleport to teleport them there.

What happened?
The game freezes.

What did you expect to happen instead? It might be obvious to you, but do it anyway!
The player should teleport to a non-colliding-position, OR, nothing should happen (function returns false), OR, the game throws a script error due to some failure on my part.

Does it happen always, once, or sometimes?
Always.

This involves one mod not currently on the portal, so kindly see attached. To reproduce just start a new game with that mod (all dependencies are on the portal), click on the console, and try to teleport to ground. I'm sure this is caused by me doing something dumb, but I'd expect a coherent error in that case, rather than a game freeze.
Attachments
factorio-current.log
(6.81 KiB) Downloaded 10 times
warptorio-classic.zip
(68.36 KiB) Downloaded 12 times
DeadMG
Fast Inserter
Fast Inserter
Posts: 102
Joined: Thu Oct 22, 2020 7:56 am
Contact:

Re: [2.0.60] Game freezes when teleporting player to non colliding position

Post by DeadMG »

Seems to occur when the destination surface has no chunks. Generating a chunk ahead of time seems to resolve the issue.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16058
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.60] Game freezes when teleporting player to non colliding position

Post by Rseding91 »

What did you provide for the "radius" value?
If you want to get ahold of me I'm almost always on Discord.
DeadMG
Fast Inserter
Fast Inserter
Posts: 102
Joined: Thu Oct 22, 2020 7:56 am
Contact:

Re: [2.0.60] Game freezes when teleporting player to non colliding position

Post by DeadMG »

0, which is an infinite search in theory, but in this case, the player is warping into the starting area of a default settings Nauvis, so there should be a ton of empty space immediately available in practice, and after generating the chunk, there is. I'd guess that the search neither generates chunks as part of the search, nor terminates when running out of generated chunks.
Rseding91
Factorio Staff
Factorio Staff
Posts: 16058
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.60] Game freezes when teleporting player to non colliding position

Post by Rseding91 »

I see. Yes, in that case it will internally default to 500'000 which is functionally search the entire generatable map. It doesn't stop when finding un-generated chunks because it has no way to know if by searching more in a given direction it finds generated ones. In this case, everything is working correctly - but the outcome is not desired.

My only recommendation is don't do find-non-colliding-position searchs on chunks that haven't been generated yet.
If you want to get ahold of me I'm almost always on Discord.
robot256
Smart Inserter
Smart Inserter
Posts: 1261
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.60] Game freezes when teleporting player to non colliding position

Post by robot256 »

This has come up before with the same result. It would be really nice if the game could detect specifically when *zero* chunks are generated and throw an error before entering a near-infinite loop. Or simply disallow calling the non-colliding position function with an infinite search radius.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
DeadMG
Fast Inserter
Fast Inserter
Posts: 102
Joined: Thu Oct 22, 2020 7:56 am
Contact:

Re: [2.0.60] Game freezes when teleporting player to non colliding position

Post by DeadMG »

I'm dumb as bricks, the documentation explicitly calls out this case and I just brainfarted reading it. My apologies!
Post Reply

Return to “Minor issues”