private void BroadcastGame()
        {
            Channel broadcastChannel = connectionManager.FindChannel(gameCollection.GetGameBroadcastingChannelNameFromIdentifier(localGame));

            if (broadcastChannel == null)
            {
                return;
            }

            StringBuilder sb = new StringBuilder("GAME ");

            sb.Append(ProgramConstants.CNCNET_PROTOCOL_REVISION);
            sb.Append(";");
            sb.Append(ProgramConstants.GAME_VERSION);
            sb.Append(";");
            sb.Append(SGPlayers.Count);
            sb.Append(";");
            sb.Append(channel.ChannelName);
            sb.Append(";");
            sb.Append(channel.UIName);
            sb.Append(";");
            if (started || Players.Count == SGPlayers.Count)
            {
                sb.Append("1");
            }
            else
            {
                sb.Append("0");
            }
            sb.Append("0"); // IsCustomPassword
            sb.Append("0"); // Closed
            sb.Append("1"); // IsLoadedGame
            sb.Append("0"); // IsLadder
            sb.Append(";");
            foreach (SavedGamePlayer sgPlayer in SGPlayers)
            {
                sb.Append(sgPlayer.Name);
                sb.Append(",");
            }

            sb.Remove(sb.Length - 1, 1);
            sb.Append(";");
            sb.Append(lblMapNameValue.Text);
            sb.Append(";");
            sb.Append(lblGameModeValue.Text);
            sb.Append(";");
            sb.Append(tunnel.Address);
            sb.Append(";");
            sb.Append(0); // LoadedGameId

            broadcastChannel.SendCTCPMessage(sb.ToString(), QueuedMessageType.SYSTEM_MESSAGE, 20);
        }
Exemple #2
0
        private void ConnectionManager_WelcomeMessageReceived(object sender, EventArgs e)
        {
            btnNewGame.AllowClick          = true;
            btnJoinGame.AllowClick         = true;
            ddCurrentChannel.AllowDropDown = true;
            tbChatInput.Enabled            = true;

            Channel cncnetChannel = connectionManager.FindChannel("#cncnet");

            cncnetChannel.Join();

            string  localGameChatChannelName = gameCollection.GetGameChatChannelNameFromIdentifier(localGameID);
            Channel localGameChatChannel     = connectionManager.FindChannel(localGameChatChannelName);

            localGameChatChannel.Join();

            string localGameBroadcastChannel = gameCollection.GetGameBroadcastingChannelNameFromIdentifier(localGameID);

            connectionManager.FindChannel(localGameBroadcastChannel).Join();

            cncnetChannel.RequestUserInfo();
            localGameChatChannel.RequestUserInfo();

            foreach (CnCNetGame game in gameCollection.GameList)
            {
                if (!game.Supported)
                {
                    continue;
                }

                if (game.InternalName.ToUpper() != localGameID)
                {
                    if (UserINISettings.Instance.IsGameFollowed(game.InternalName.ToUpper()))
                    {
                        connectionManager.FindChannel(game.GameBroadcastChannel).Join();
                        followedGames.Add(game.InternalName);
                    }
                }
            }
        }