<commit_before>using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.NetworkSystem;
using UnityEngine.SceneManagement;

public class CaptainsMessNetworkManager : CaptainsMessLobbyManager
{
    public string broadcastIdentifier = "CM";
    public string deviceId;
    public string peerId;
    public float startHostingDelay = 2; // Look for a server for this many seconds before starting one ourself
    public float allReadyCountdownDuration = 4; // Wait for this many seconds after people are ready before starting the game
    public bool verboseLogging = false;

    public CaptainsMessServer discoveryServer;
    public CaptainsMessClient discoveryClient;
    public CaptainsMessListener listener;
    public CaptainsMessPlayer localPlayer;

    public float allReadyCountdown = 0;
    public bool forceServer = false;

    private string maybeStartHostingFunction;
    private bool gameHasStarted = false;
    private bool joinedLobby = false;

    public virtual void Start ()
    {
        deviceId = SystemInfo.deviceUniqueIdentifier;
        peerId = deviceId.Substring(0, 8);

        discoveryServer.Setup(this);
        discoveryClient.Setup(this);

        if (singleton != this)
        {
            Debug.LogWarning("#CaptainsMess# DUPLICATE CAPTAINS MESS!");
            Destroy(gameObject);
        }

        Debug.Log(String.Format("#CaptainsMess# Initialized peer {0}, \'{1}\', {2}-{3} players",
            peerId, broadcastIdentifier, minPlayers, maxPlayers));
    }

    public void InitNetworkTransport()
    {
        NetworkTransport.Init();
    }

    public void ShutdownNetworkTransport()
    {
        NetworkTransport.Shutdown();
    }

    public void StartHosting()
    {
        if (verboseLogging) {
            Debug.Log("#CaptainsMess# StartHosting");
        }

        // Stop the broadcast server so we can start a regular hosting server
        StopServer();

        // Delay briefly to let things settle down<commit_msg>Device IDs no longer use 'System.deviceUniqueIdenfier'<commit_after>using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.NetworkSystem;
using UnityEngine.SceneManagement;

public class CaptainsMessNetworkManager : CaptainsMessLobbyManager
{
    public string broadcastIdentifier = "CM";
    public string deviceId;
    public string peerId;
    public float startHostingDelay = 2; // Look for a server for this many seconds before starting one ourself
    public float allReadyCountdownDuration = 4; // Wait for this many seconds after people are ready before starting the game
    public bool verboseLogging = false;

    public CaptainsMessServer discoveryServer;
    public CaptainsMessClient discoveryClient;
    public CaptainsMessListener listener;
    public CaptainsMessPlayer localPlayer;

    public float allReadyCountdown = 0;
    public bool forceServer = false;

    private string maybeStartHostingFunction;
    private bool gameHasStarted = false;
    private bool joinedLobby = false;

    public virtual void Start ()
    {
        deviceId = GetUniqueDeviceId();
        peerId = deviceId.Substring(0, 8);

        discoveryServer.Setup(this);
        discoveryClient.Setup(this);

        if (singleton != this)
        {
            Debug.LogWarning("#CaptainsMess# DUPLICATE CAPTAINS MESS!");
            Destroy(gameObject);
        }

        Debug.Log(String.Format("#CaptainsMess# Initialized peer {0}, \'{1}\', {2}-{3} players",
            peerId, broadcastIdentifier, minPlayers, maxPlayers));
    }

    string GetUniqueDeviceId()
    {
        // NOTE: Don't use SystemInfo.deviceUniqueIdentifier here because it causes Android
        // to ask for permission to "make and manage phone calls?" which sounds suspicious.
        // Using this alternate method means that the ID isn't truly unique. Each time the app is
        // uninstalled/reinstalled a new ID will be generated.
        // This won't matter for normal connections but might matter if you want to use the ID
        // to track unique players met (eg. Spaceteam has achievements for number of players met).

        string savedId = PlayerPrefs.GetString("CaptainsMessDeviceId");
        if (string.IsNullOrEmpty(savedId))
        {
            savedId = GenerateNewUniqueID();
            PlayerPrefs.SetString("CaptainsMessDeviceId", savedId);
        }
        return savedId;
    }

    string GenerateNewUniqueID()
    {
        return Guid.NewGuid().ToString().Substring(0,8);
    }

    public void InitNetworkTransport()
    {
        NetworkTransport.Init();
    }

    public void ShutdownNetworkTransport()
    {
        NetworkTransport.Shutdown();
    }

    public void StartHosting()
    {
        if (verboseLogging) {
            Debug.Log("#CaptainsMess# StartHosting");
        }

        // Stop the broadcast server so we can start a regular hosting server
        StopServer();

        // Delay briefly to let things settle down
{'fraction_non_alphanumeric': 0.07592233009708738, 'fraction_numerical': 0.003883495145631068, 'mean_word_length': 2.980680061823802, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5444262', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1281, 'n_words': 422}