Skip to content

fix(unicylce cleanup): defer cleanup until vehicle callbacks complete - #226

Open
florinm03 wants to merge 1 commit into
TheHellBox:masterfrom
florinm03:fix/re-entering-vehicle-error
Open

fix(unicylce cleanup): defer cleanup until vehicle callbacks complete#226
florinm03 wants to merge 1 commit into
TheHellBox:masterfrom
florinm03:fix/re-entering-vehicle-error

Conversation

@florinm03

Copy link
Copy Markdown
Contributor

Fixes #218.

Basically, when walking mode exits, walk.lua does this:

local unicycle = getCurrentUnicycle()
be:enterVehicle(0, vehicle)
unicycleId = unicycle:getId()

The multiplayer vehicle manager then loops through all vehicles and deletes every unicycle whose ID is not new_id.

walk.lua still had the Lua variable referring to the old unicycle and called:

unicycle:getId()

The Lua variable still existed, but the underlying BeamNG vehicle object had already been destroyed. That produced the invalid userdata error.

The fix moves the deletion to the next update tick so that the game doesn't call non-existent objects.

Tested it on a few new restarts of the game and mod and it did not happen anymore. :)

Errors: image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exiting and re-entering vehicle LUA error

1 participant