YARM - Resource Monitor

by Narc

This mod helps you to keep track of your mining sites, with useful data such as the percent mined, and estimated time to depletion.

Utilities
8 months ago
0.14 - 2.0
157K
Mining

b Edge case crash in resmon.update_players

2 months ago
    local player_data = storage.player_data[player.index]

    if not player_data then
        resmon.init_player(player) -- if this code path is triggered...
    elseif not player.connected and player_data.current_site then
        resmon.clear_current_site(player)
    end

    if player_data.current_site then -- this will crash
        ...

if player_data is nil, initialization is performed, but then player_data is never assigned to a non-nil value after, so an attempt is made to index nil.

The fix could be something like:

if player_data then
    if player_data.current_site then
        ...

since both parts of the if/else assume player_data is accessible. Alternatively, player_data could be assigned after initialization:

    if not player_data then
        resmon.init_player(player)
        player_data = storage.player_data[player.index]

New response