File size: 1,515 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
class SyncPlayerList
{
ref array<ref SyncPlayer> m_PlayerList;
void CreatePlayerList()
{
if (GetGame().IsServer())
{
m_PlayerList = new array<ref SyncPlayer>();
array<PlayerIdentity> identities = new array<PlayerIdentity>();
GetGame().GetPlayerIndentities(identities);
foreach (auto identity : identities)
{
SyncPlayer sync_player = new SyncPlayer;
sync_player.m_Identity = identity;
sync_player.m_UID = identity.GetPlainId();
sync_player.m_PlayerName = identity.GetPlainName();
m_PlayerList.Insert(sync_player);
}
}
}
static SyncPlayerList Compare(SyncPlayerList a, SyncPlayerList b)
{
SyncPlayerList new_list = new SyncPlayerList;
new_list.m_PlayerList = new array<ref SyncPlayer>;
if (!a && b && b.m_PlayerList)
{
foreach (SyncPlayer player3 : b.m_PlayerList)
{
new_list.m_PlayerList.Insert(player3);
}
}
else if (a && a.m_PlayerList && !b)
{
foreach (SyncPlayer player4 : a.m_PlayerList)
{
new_list.m_PlayerList.Insert(player4);
}
}
else if (a && a.m_PlayerList && b && b.m_PlayerList)
{
array<ref SyncPlayer> array_a = a.m_PlayerList;
array<ref SyncPlayer> array_b = b.m_PlayerList;
foreach (SyncPlayer player : array_b)
{
bool found = false;
foreach (SyncPlayer player2 : array_a)
{
if (player.m_UID == player2.m_UID)
{
found = true;
break;
}
}
if (!found)
{
new_list.m_PlayerList.Insert(player);
}
}
}
return new_list;
}
} |