<commit_before>﻿using System.Collections.Generic;
using System.Linq;
using UnityEngine;

class NetworkLeaderboard : MonoBehaviour
{
    public readonly List<LeaderboardEntry> Entries = new List<LeaderboardEntry>();

    static NetworkLeaderboard instance;
    public static NetworkLeaderboard Instance
    {
        get { return instance; }
    }

    void OnNetworkInstantiate(NetworkMessageInfo info)
    {
        instance = this;

        if (Network.isServer)
            Entries.Add(new LeaderboardEntry
            {
                Ping = Network.GetLastPing(Network.player),
                NetworkPlayer = Network.player
            });
    }

    void Update()
    {
        if (Network.isServer)
        {
            foreach (var entry in Entries)
                entry.Ping = Network.GetLastPing(entry.NetworkPlayer);
        }

        // update colors
        var isFirst = true;
        foreach (var entry in Entries.OrderByDescending(x => x.Kills))
        {
            if (!PlayerRegistry.For.ContainsKey(Network.player))
                continue;

            var player = PlayerRegistry.For[entry.NetworkPlayer];
            if (entry.NetworkPlayer == Network.player)
                player.Color = new Color(114 / 255f, 222 / 255f, 194 / 255f); // cyan
            else if (isFirst)
                player.Color = new Color(255 / 255f, 166 / 255f, 27 / 255f); // orange
            else
                player.Color = Color.white;

            isFirst = false;
        }
    }

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        // Sync entry count
        int entryCount = stream.isWriting ? Entries.Count : 0;
        stream.Serialize(ref entryCount);

        // Tidy up collection size
        if (stream.isReading)<commit_msg>leaderboard fix<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using UnityEngine;

class NetworkLeaderboard : MonoBehaviour
{
    public readonly List<LeaderboardEntry> Entries = new List<LeaderboardEntry>();

    static NetworkLeaderboard instance;
    public static NetworkLeaderboard Instance
    {
        get { return instance; }
    }

    void OnNetworkInstantiate(NetworkMessageInfo info)
    {
        instance = this;

        if (Network.isServer)
            Entries.Add(new LeaderboardEntry
            {
                Ping = Network.GetLastPing(Network.player),
                NetworkPlayer = Network.player
            });
    }

    void Update()
    {
        if (Network.isServer)
        {
            foreach (var entry in Entries)
                entry.Ping = Network.GetLastPing(entry.NetworkPlayer);
        }

        // update colors
        var isFirst = true;
        foreach (var entry in Entries.OrderByDescending(x => x.Kills))
        {
            if (!PlayerRegistry.For.ContainsKey(Network.player) ||
                !PlayerRegistry.For.ContainsKey(entry.NetworkPlayer))
                continue;
            

            var player = PlayerRegistry.For[entry.NetworkPlayer];
            if (entry.NetworkPlayer == Network.player)
                player.Color = new Color(114 / 255f, 222 / 255f, 194 / 255f); // cyan
            else if (isFirst)
                player.Color = new Color(255 / 255f, 166 / 255f, 27 / 255f); // orange
            else
                player.Color = Color.white;

            isFirst = false;
        }
    }

    void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
    {
        // Sync entry count
        int entryCount = stream.isWriting ? Entries.Count : 0;
        stream.Serialize(ref entryCount);

        // Tidy up collection size
        if (stream.isReading)
{'fraction_non_alphanumeric': 0.08662489784799782, 'fraction_numerical': 0.0196131844184146, 'mean_word_length': 1.8509316770186335, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3851132', 'n_tokens_mistral': 1062, 'n_tokens_neox': 958, 'n_words': 233}