1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2024-12-04 09:43:00 +02:00

Merge pull request #182 from Oarcinae/174-crash-join-another-spawn

Fix crash when selecting shared spawn for a player that just left. No…
This commit is contained in:
Oarcinae 2024-10-12 22:08:59 -04:00 committed by GitHub
commit 7318113af7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -760,6 +760,11 @@ function RemoveOrResetPlayer(player, remove_player)
if (remove_player) then
game.remove_offline_players({ player })
end
-- Refresh the shared spawn spawn gui for all players
for _,p in pairs(game.connected_players) do
RefreshSharedSpawnFrameIfExist(p)
end
end
---Searches all unique spawns for the primary one for a player. This will return null if they joined someeone else's spawn.
@ -771,6 +776,7 @@ function FindPrimaryUniqueSpawn(player_name)
return spawns[player_name]
end
end
return nil
end
---Find the primary home spawn of a player, if one exists. It could be they joined a shared spawn.

View File

@ -842,7 +842,9 @@ function SharedSpawnSelect(gui_element, player)
local button = gui_element.parent.join_other_spawn
local primary_spawn = FindPrimaryUniqueSpawn(host_name)
if (IsSharedSpawnOpen(primary_spawn.surface_name, host_name) and not IsSharedSpawnFull(primary_spawn.surface_name, host_name)) then
if (primary_spawn and
IsSharedSpawnOpen(primary_spawn.surface_name, host_name) and
not IsSharedSpawnFull(primary_spawn.surface_name, host_name)) then
global.spawn_choices[player.name].host = host_name
button.enabled = true
button.caption = { "oarc-join-shared-button-enable", host_name, primary_spawn.surface_name }