Esempio n. 1
0
        /// <summary>
        /// SV_SendClientMessages
        /// </summary>
        public static void SendClientMessages()
        {
            // update frags, names, etc
            UpdateToReliableMessages();

            // build individual updates
            for (int i = 0; i < svs.maxclients; i++)
            {
                Host.HostClient = svs.clients[i];

                if (!Host.HostClient.active)
                {
                    continue;
                }

                if (Host.HostClient.spawned)
                {
                    if (!SendClientDatagram(Host.HostClient))
                    {
                        continue;
                    }
                }
                else
                {
                    // the player isn't totally in the game yet
                    // send small keepalive messages if too much time has passed
                    // send a full message when the next signon stage has been requested
                    // some other message data (name changes, etc) may accumulate
                    // between signon stages
                    if (!Host.HostClient.sendsignon)
                    {
                        if (Host.RealTime - Host.HostClient.last_message > 5)
                        {
                            SendNop(Host.HostClient);
                        }
                        continue;       // don't send out non-signon messages
                    }
                }

                // check for an overflowed message.  Should only happen
                // on a very f****d up connection that backs up a lot, then
                // changes level
                if (Host.HostClient.message.IsOveflowed)
                {
                    DropClient(true);
                    Host.HostClient.message.IsOveflowed = false;
                    continue;
                }

                if (Host.HostClient.message.Length > 0 || Host.HostClient.dropasap)
                {
                    if (!Net.CanSendMessage(Host.HostClient.netconnection))
                    {
                        continue;
                    }

                    if (Host.HostClient.dropasap)
                    {
                        DropClient(false);      // went to another level
                    }
                    else
                    {
                        if (Net.SendMessage(Host.HostClient.netconnection, Host.HostClient.message) == -1)
                        {
                            DropClient(true);   // if the message couldn't send, kick off
                        }
                        Host.HostClient.message.Clear();
                        Host.HostClient.last_message = Host.RealTime;
                        Host.HostClient.sendsignon   = false;
                    }
                }
            }

            // clear muzzle flashes
            CleanupEnts();
        }