Skip to content

Fix nil index crash in update_item_count_settings#19

Open
sparr wants to merge 1 commit intoNexela:masterfrom
sparr:avoid_nil_player_index
Open

Fix nil index crash in update_item_count_settings#19
sparr wants to merge 1 commit intoNexela:masterfrom
sparr:avoid_nil_player_index

Conversation

@sparr
Copy link

@sparr sparr commented Jun 19, 2023

When another mod changes a global mod setting, event.player_index will be nil and this function will crash.

e.g. this happens:

The mod Project Cybersyn (1.2.16) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event cybersyn::on_init()
The mod Picker Inventory Tools (1.1.15) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event PickerInventoryTools::on_runtime_mod_setting_changed (ID 61)
__stdlib__/stdlib/event/event.lua:368: __PickerInventoryTools__/scripts/item-count.lua:43: bad argument #3 of 3 to '__index' (string expected, got nil)
stack traceback:
    [C]: in function 'error'
    __stdlib__/stdlib/event/event.lua:368: in function 'dispatch_event'
    __stdlib__/stdlib/event/event.lua:438: in function <__stdlib__/stdlib/event/event.lua:396>
stack traceback:
    [C]: in function '__newindex'
    __cybersyn__/scripts/main.lua:940: in function <__cybersyn__/scripts/main.lua:937>

when Cybersyn does this:

local setting = settings.global["cybersyn-invert-sign"]
setting.value = false
settings.global["cybersyn-invert-sign"] = setting

Signed-off-by: Clarence "Sparr" Risher <sparr0@gmail.com>
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.

1 participant