[Oxyd] [0.17.4] Desync when defines.events.on_lua_shortcut handler tries to modify player.cursor_stack

This subforum contains all the issues which we already resolved.
Post Reply
Atria
Inserter
Inserter
Posts: 49
Joined: Sat Jul 09, 2016 10:25 am
Contact:

[Oxyd] [0.17.4] Desync when defines.events.on_lua_shortcut handler tries to modify player.cursor_stack

Post by Atria » Sun Mar 03, 2019 4:17 pm

Description:
My mod is using new shortcuts to insert item into player's cursor_stack. But when event handler of defines.events.on_lua_shortcut tries to call player.clean_cursor() or player.cursor_stack.can_set_stack(...) or player.cursor_stack.set_stack(...) it causes a client to desync.

Code in question:

Code: Select all

function OnShortCut(event)
	local player = game.players[event.player_index]
	if player.clean_cursor() then
		local stack = player.cursor_stack
		if player.cursor_stack and stack.can_set_stack({ name = "steel-chest" }) then
			stack.set_stack({ name = "steel-chest" })
		end
	end
end

script.on_event(defines.events.on_lua_shortcut, OnShortCut)
Steps to reproduce:
-Install attached mod on server and client
-Start server and connect with client
-Open shortcut tool list
-Click on new shortcut (see attached screenshot)
-Enjoy desync

Attached mod, screenshot and desync report.
Attachments
MiniMod_1.0.0.zip
Minified mod that causes the desync
(1.17 KiB) Downloaded 18 times
desync-report-2019-03-03_17-13-00.zip
Desync report
(5.25 MiB) Downloaded 12 times
desync.png
Screenshot right before desync
desync.png (125.04 KiB) Viewed 241 times

Oxyd
Factorio Staff
Factorio Staff
Posts: 1242
Joined: Thu May 07, 2015 8:42 am
Contact:

Re: [Oxyd] [0.17.4] Desync when defines.events.on_lua_shortcut handler tries to modify player.cursor_stack

Post by Oxyd » Mon Mar 04, 2019 3:40 pm

Thanks, fixed in 0.17.5.

Post Reply

Return to “Resolved Problems and Bugs”

Who is online

Users browsing this forum: No registered users