[2.0.55] Teleporting car to other surface invalidates reference to non-player driver

Bugs which we just recently fixed in our development version and will reach you in the next release.
robot256
Smart Inserter
Smart Inserter
Posts: 1224
Joined: Sun Mar 17, 2019 1:52 am
Contact:

[2.0.55] Teleporting car to other surface invalidates reference to non-player driver

Post by robot256 »

What did you do?
1. Place a non-player character entity inside a car.
2. Store a LuaEntity reference to the non-player character entity.
3. Used a script to teleport the car to another surface.

To replicate, load the attached save and run the following command:

Code: Select all

/c game.print("Before teleport, storage.driver.valid="..tostring(storage.driver.valid)); storage.vehicle.teleport({0,0},"surface2"); game.print("After teleport, storage.driver.valid="..tostring(storage.driver.valid).." and storage.vehicle.get_driver().valid="..tostring(storage.vehicle.get_driver().valid))
What happened?
The stored LuaEntity reference is now invalid even though the same non-player character entity still exists in the car.
What did you expect to happen instead?
I expected the stored LuaEntity reference to remain valid, since the entity it references still exists.
Does it happen always, once, or sometimes?
Always. Note that Lua references to player-controlled characters do remain valid when teleported.
Context:
This bug manifests when Vehicle Wagon 2 attempts to teleport an AAI Programmable Vehicles "AI Car" to the hidden storage surface. When it does this, the LuaEntity reference that AAI stores to the non-player AI driver character driving the car becomes invalid even though the AI driver character still exists in the car (same unit_number), and AAI creates a new (second) AI driver character.

If this is intentional, then it would be nice to mention it in the documentation for LuaEntity::teleport().
Attachments
car_teleport_driver_invalid.zip
(2.26 MiB) Downloaded 14 times
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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15793
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.55] Teleporting car to other surface invalidates reference to non-player driver

Post by Rseding91 »

Thanks for the report. This is now fixed for the next release.
If you want to get ahold of me I'm almost always on Discord.
robot256
Smart Inserter
Smart Inserter
Posts: 1224
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: [2.0.55] Teleporting car to other surface invalidates reference to non-player driver

Post by robot256 »

Thank you!
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.
Post Reply

Return to “Resolved for the next release”