From 1d6d573e1b3c653d2eea5064aeeb76bd446366c8 Mon Sep 17 00:00:00 2001
From: hjpalpha <75081997+hjpalpha@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:59:13 +0100
Subject: [PATCH] fix(match2): extradata for 1v1 maps in team matches
 incomplete on craft wikis (#5168)

---
 .../starcraft_starcraft2/match_group_input_starcraft.lua      | 4 ++--
 .../match2/wikis/stormgate/match_group_input_custom.lua       | 4 ++--
 components/match2/wikis/warcraft/match_group_input_custom.lua | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua
index 64719f2c2cf..52a1e2696b9 100644
--- a/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua
+++ b/components/match2/commons/starcraft_starcraft2/match_group_input_starcraft.lua
@@ -388,8 +388,8 @@ function MapFunctions.getExtraData(match, map, opponents)
 
 	---@type table[]
 	local players = {
-		Array.extractValues(map.opponents[1].players)[1],
-		Array.extractValues(map.opponents[2].players)[1],
+		Array.filter(Array.extractValues(map.opponents[1].players or {}), Logic.isNotEmpty)[1],
+		Array.filter(Array.extractValues(map.opponents[2].players or {}), Logic.isNotEmpty)[1],
 	}
 
 	extradata.opponent1 = players[1].player
diff --git a/components/match2/wikis/stormgate/match_group_input_custom.lua b/components/match2/wikis/stormgate/match_group_input_custom.lua
index 3e60328a416..bbcfbdda383 100644
--- a/components/match2/wikis/stormgate/match_group_input_custom.lua
+++ b/components/match2/wikis/stormgate/match_group_input_custom.lua
@@ -324,8 +324,8 @@ function MapFunctions.getExtraData(match, map, opponents)
 
 	---@type table[]
 	local players = {
-		Array.extractValues(map.opponents[1].players)[1],
-		Array.extractValues(map.opponents[2].players)[1],
+		Array.filter(Array.extractValues(map.opponents[1].players or {}), Logic.isNotEmpty)[1],
+		Array.filter(Array.extractValues(map.opponents[2].players or {}), Logic.isNotEmpty)[1],
 	}
 
 	extradata.opponent1 = players[1].player
diff --git a/components/match2/wikis/warcraft/match_group_input_custom.lua b/components/match2/wikis/warcraft/match_group_input_custom.lua
index 9a8bb7ff74c..4419f8c8a24 100644
--- a/components/match2/wikis/warcraft/match_group_input_custom.lua
+++ b/components/match2/wikis/warcraft/match_group_input_custom.lua
@@ -356,8 +356,8 @@ function MapFunctions.getExtraData(match, map, opponents)
 
 	---@type table[]
 	local players = {
-		Array.extractValues(map.opponents[1].players)[1],
-		Array.extractValues(map.opponents[2].players)[1],
+		Array.filter(Array.extractValues(map.opponents[1].players or {}), Logic.isNotEmpty)[1],
+		Array.filter(Array.extractValues(map.opponents[2].players or {}), Logic.isNotEmpty)[1],
 	}
 
 	extradata.opponent1 = players[1].player