ForwardToServer() 공개 정적인 메소드

public static ForwardToServer ( ) : void
리턴 void
예제 #1
0
        /// <summary>
        /// Host_Pause_f
        /// </summary>
        private static void Pause_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }
            if (_Pausable.Value == 0)
            {
                Server.ClientPrint("Pause not allowed.\n");
            }
            else
            {
                Server.sv.paused = !Server.sv.paused;

                if (Server.sv.paused)
                {
                    Server.BroadcastPrint("{0} paused the game\n", Progs.GetString(Server.Player.v.netname));
                }
                else
                {
                    Server.BroadcastPrint("{0} unpaused the game\n", Progs.GetString(Server.Player.v.netname));
                }

                // send notification to all clients
                Server.sv.reliable_datagram.WriteByte(Protocol.svc_setpause);
                Server.sv.reliable_datagram.WriteByte(Server.sv.paused ? 1 : 0);
            }
        }
예제 #2
0
        /// <summary>
        /// Host_Ping_f
        /// </summary>
        private static void Ping_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            Server.ClientPrint("Client ping times:\n");
            for (int i = 0; i < Server.svs.maxclients; i++)
            {
                client_t client = Server.svs.clients[i];
                if (!client.active)
                {
                    continue;
                }
                float total = 0;
                for (int j = 0; j < Server.NUM_PING_TIMES; j++)
                {
                    total += client.ping_times[j];
                }
                total /= Server.NUM_PING_TIMES;
                Server.ClientPrint("{0,4} {1}\n", (int)(total * 1000), client.name);
            }
        }
예제 #3
0
        /// <summary>
        /// Host_Noclip_f
        /// </summary>
        private static void Noclip_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Progs.GlobalStruct.deathmatch > 0 && !Host.HostClient.privileged)
            {
                return;
            }

            if (Server.Player.v.movetype != Movetypes.MOVETYPE_NOCLIP)
            {
                Host.NoClipAngleHack     = true;
                Server.Player.v.movetype = Movetypes.MOVETYPE_NOCLIP;
                Server.ClientPrint("noclip ON\n");
            }
            else
            {
                Host.NoClipAngleHack     = false;
                Server.Player.v.movetype = Movetypes.MOVETYPE_WALK;
                Server.ClientPrint("noclip OFF\n");
            }
        }
예제 #4
0
        // Host_Name_f
        static void Name_f()
        {
            if (Cmd.Argc == 1)
            {
                Con.Print("\"name\" is \"{0}\"\n", Client.Name);
                return;
            }

            string newName;

            if (Cmd.Argc == 2)
            {
                newName = Cmd.Argv(1);
            }
            else
            {
                newName = Cmd.Args;
            }

            if (newName.Length > 16)
            {
                newName = newName.Remove(15);
            }

            if (Cmd.Source == cmd_source_t.src_command)
            {
                if (Client.Name == newName)
                {
                    return;
                }

                Cvar.Set("_cl_name", newName);
                if (Client.Cls.state == ClientActivityState.Connected)
                {
                    Cmd.ForwardToServer();
                }

                return;
            }

            if (!String.IsNullOrEmpty(Host.HostClient.name) && Host.HostClient.name != "unconnected")
            {
                if (Host.HostClient.name != newName)
                {
                    Con.Print("{0} renamed to {1}\n", Host.HostClient.name, newName);
                }
            }

            Host.HostClient.name            = newName;
            Host.HostClient.edict.v.netname = Progs.NewString(newName);

            // send notification to all clients
            MessageWriter msg = Server.sv.reliable_datagram;

            msg.WriteByte(Protocol.svc_updatename);
            msg.WriteByte(Host.ClientNum);
            msg.WriteString(newName);
        }
예제 #5
0
        // Host_Color_f
        static void Color_f()
        {
            if (Cmd.Argc == 1)
            {
                Con.Print("\"color\" is \"{0} {1}\"\n", ((int)Client.Color) >> 4, ((int)Client.Color) & 0x0f);
                Con.Print("color <0-13> [0-13]\n");
                return;
            }

            int top, bottom;

            if (Cmd.Argc == 2)
            {
                top = bottom = Common.atoi(Cmd.Argv(1));
            }
            else
            {
                top    = Common.atoi(Cmd.Argv(1));
                bottom = Common.atoi(Cmd.Argv(2));
            }

            top &= 15;
            if (top > 13)
            {
                top = 13;
            }

            bottom &= 15;
            if (bottom > 13)
            {
                bottom = 13;
            }

            int playercolor = top * 16 + bottom;

            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cvar.Set("_cl_color", playercolor);
                if (Client.Cls.state == ClientActivityState.Connected)
                {
                    Cmd.ForwardToServer();
                }

                return;
            }


            Host.HostClient.colors       = playercolor;
            Host.HostClient.edict.v.team = bottom + 1;

            // send notification to all clients
            MessageWriter msg = Server.sv.reliable_datagram;

            msg.WriteByte(Protocol.svc_updatecolors);
            msg.WriteByte(Host.ClientNum);
            msg.WriteByte(Host.HostClient.colors);
        }
예제 #6
0
        // Host_Tell_f
        static void Tell_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Cmd.Argc < 3)
            {
                return;
            }

            string text = Host.HostClient.name + ": ";
            string p    = Cmd.Args;

            // remove quotes if present
            if (p.StartsWith("\""))
            {
                p = p.Substring(1, p.Length - 2);
            }

            text += p + "\n";

            client_t save = Host.HostClient;

            for (int j = 0; j < Server.svs.maxclients; j++)
            {
                client_t client = Server.svs.clients[j];
                if (!client.active || !client.spawned)
                {
                    continue;
                }

                if (client.name == Cmd.Argv(1))
                {
                    continue;
                }

                Host.HostClient = client;
                Server.ClientPrint(text);
                break;
            }
            Host.HostClient = save;
        }
예제 #7
0
        /// <summary>
        /// Host_Kill_f
        /// </summary>
        private static void Kill_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Server.Player.v.health <= 0)
            {
                Server.ClientPrint("Can't suicide -- allready dead!\n");
                return;
            }

            Progs.GlobalStruct.time = (float)Server.sv.time;
            Progs.GlobalStruct.self = Server.EdictToProg(Server.Player);
            Progs.Execute(Progs.GlobalStruct.ClientKill);
        }
예제 #8
0
        /// <summary>
        /// Host_Notarget_f
        /// </summary>
        private static void Notarget_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged)
            {
                return;
            }

            Server.Player.v.flags = (int)Server.Player.v.flags ^ EdictFlags.FL_NOTARGET;
            if (((int)Server.Player.v.flags & EdictFlags.FL_NOTARGET) == 0)
            {
                Server.ClientPrint("notarget OFF\n");
            }
            else
            {
                Server.ClientPrint("notarget ON\n");
            }
        }
예제 #9
0
        /// <summary>
        /// Host_God_f
        /// Sets client to godmode
        /// </summary>
        static void God_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged)
            {
                return;
            }

            Server.Player.v.flags = (int)Server.Player.v.flags ^ EdictFlags.FL_GODMODE;
            if (((int)Server.Player.v.flags & EdictFlags.FL_GODMODE) == 0)
            {
                Server.ClientPrint("godmode OFF\n");
            }
            else
            {
                Server.ClientPrint("godmode ON\n");
            }
        }
예제 #10
0
        /// <summary>
        /// Host_Fly_f
        /// Sets client to flymode
        /// </summary>
        private static void Fly_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Progs.GlobalStruct.deathmatch > 0 && !Host.HostClient.privileged)
            {
                return;
            }

            if (Server.Player.v.movetype != Movetypes.MOVETYPE_FLY)
            {
                Server.Player.v.movetype = Movetypes.MOVETYPE_FLY;
                Server.ClientPrint("flymode ON\n");
            }
            else
            {
                Server.Player.v.movetype = Movetypes.MOVETYPE_WALK;
                Server.ClientPrint("flymode OFF\n");
            }
        }
예제 #11
0
        /// <summary>
        /// Host_Status_f
        /// </summary>
        private static void Status_f()
        {
            bool flag = true;

            if (Cmd.Source == cmd_source_t.src_command)
            {
                if (!Server.sv.active)
                {
                    Cmd.ForwardToServer();
                    return;
                }
            }
            else
            {
                flag = false;
            }

            StringBuilder sb = new StringBuilder(256);

            sb.Append(String.Format("host:    {0}\n", Cvar.GetString("hostname")));
            sb.Append(String.Format("version: {0:F2}\n", QDef.VERSION));
            if (Net.TcpIpAvailable)
            {
                sb.Append("tcp/ip:  ");
                sb.Append(Net.MyTcpIpAddress);
                sb.Append('\n');
            }

            sb.Append("map:     ");
            sb.Append(Server.sv.name);
            sb.Append('\n');
            sb.Append(String.Format("players: {0} active ({1} max)\n\n", Net.ActiveConnections, Server.svs.maxclients));
            for (int j = 0; j < Server.svs.maxclients; j++)
            {
                client_t client = Server.svs.clients[j];
                if (!client.active)
                {
                    continue;
                }

                int seconds = (int)(Net.Time - client.netconnection.connecttime);
                int hours, minutes = seconds / 60;
                if (minutes > 0)
                {
                    seconds -= (minutes * 60);
                    hours    = minutes / 60;
                    if (hours > 0)
                    {
                        minutes -= (hours * 60);
                    }
                }
                else
                {
                    hours = 0;
                }
                sb.Append(String.Format("#{0,-2} {1,-16}  {2}  {2}:{4,2}:{5,2}",
                                        j + 1, client.name, (int)client.edict.v.frags, hours, minutes, seconds));
                sb.Append("   ");
                sb.Append(client.netconnection.address);
                sb.Append('\n');
            }

            if (flag)
            {
                Con.Print(sb.ToString());
            }
            else
            {
                Server.ClientPrint(sb.ToString());
            }
        }
예제 #12
0
        /// <summary>
        /// Host_Say
        /// </summary>
        private static void Say(bool teamonly)
        {
            bool fromServer = false;

            if (Cmd.Source == cmd_source_t.src_command)
            {
                if (Client.cls.state == cactive_t.ca_dedicated)
                {
                    fromServer = true;
                    teamonly   = false;
                }
                else
                {
                    Cmd.ForwardToServer();
                    return;
                }
            }

            if (Cmd.Argc < 2)
            {
                return;
            }

            client_t save = Host.HostClient;

            string p = Cmd.Args;

            // remove quotes if present
            if (p.StartsWith("\""))
            {
                p = p.Substring(1, p.Length - 2);
            }

            // turn on color set 1
            string text;

            if (!fromServer)
            {
                text = (char)1 + save.name + ": ";
            }
            else
            {
                text = (char)1 + "<" + Net.HostName + "> ";
            }

            text += p + "\n";

            for (int j = 0; j < Server.svs.maxclients; j++)
            {
                client_t client = Server.svs.clients[j];
                if (client == null || !client.active || !client.spawned)
                {
                    continue;
                }
                if (Host.TeamPlay != 0 && teamonly && client.edict.v.team != save.edict.v.team)
                {
                    continue;
                }
                Host.HostClient = client;
                Server.ClientPrint(text);
            }
            Host.HostClient = save;
        }
예제 #13
0
        /// <summary>
        /// Host_Give_f
        /// </summary>
        private static void Give_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                Cmd.ForwardToServer();
                return;
            }

            if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged)
            {
                return;
            }

            string t = Cmd.Argv(1);
            int    v = Common.atoi(Cmd.Argv(2));

            if (String.IsNullOrEmpty(t))
            {
                return;
            }

            switch (t[0])
            {
            case '0':
            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
            case '6':
            case '7':
            case '8':
            case '9':
                // MED 01/04/97 added hipnotic give stuff
                if (Common.GameKind == GameKind.Hipnotic)
                {
                    if (t[0] == '6')
                    {
                        if (t[1] == 'a')
                        {
                            Server.Player.v.items = (int)Server.Player.v.items | QItems.HIT_PROXIMITY_GUN;
                        }
                        else
                        {
                            Server.Player.v.items = (int)Server.Player.v.items | QItems.IT_GRENADE_LAUNCHER;
                        }
                    }
                    else if (t[0] == '9')
                    {
                        Server.Player.v.items = (int)Server.Player.v.items | QItems.HIT_LASER_CANNON;
                    }
                    else if (t[0] == '0')
                    {
                        Server.Player.v.items = (int)Server.Player.v.items | QItems.HIT_MJOLNIR;
                    }
                    else if (t[0] >= '2')
                    {
                        Server.Player.v.items = (int)Server.Player.v.items | (QItems.IT_SHOTGUN << (t[0] - '2'));
                    }
                }
                else
                {
                    if (t[0] >= '2')
                    {
                        Server.Player.v.items = (int)Server.Player.v.items | (QItems.IT_SHOTGUN << (t[0] - '2'));
                    }
                }
                break;

            case 's':
                if (Common.GameKind == GameKind.Rogue)
                {
                    Progs.SetEdictFieldFloat(Server.Player, "ammo_shells1", v);
                }

                Server.Player.v.ammo_shells = v;
                break;

            case 'n':
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (Progs.SetEdictFieldFloat(Server.Player, "ammo_nails1", v))
                    {
                        if (Server.Player.v.weapon <= QItems.IT_LIGHTNING)
                        {
                            Server.Player.v.ammo_nails = v;
                        }
                    }
                }
                else
                {
                    Server.Player.v.ammo_nails = v;
                }
                break;

            case 'l':
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (Progs.SetEdictFieldFloat(Server.Player, "ammo_lava_nails", v))
                    {
                        if (Server.Player.v.weapon > QItems.IT_LIGHTNING)
                        {
                            Server.Player.v.ammo_nails = v;
                        }
                    }
                }
                break;

            case 'r':
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (Progs.SetEdictFieldFloat(Server.Player, "ammo_rockets1", v))
                    {
                        if (Server.Player.v.weapon <= QItems.IT_LIGHTNING)
                        {
                            Server.Player.v.ammo_rockets = v;
                        }
                    }
                }
                else
                {
                    Server.Player.v.ammo_rockets = v;
                }
                break;

            case 'm':
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (Progs.SetEdictFieldFloat(Server.Player, "ammo_multi_rockets", v))
                    {
                        if (Server.Player.v.weapon > QItems.IT_LIGHTNING)
                        {
                            Server.Player.v.ammo_rockets = v;
                        }
                    }
                }
                break;

            case 'h':
                Server.Player.v.health = v;
                break;

            case 'c':
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (Progs.SetEdictFieldFloat(Server.Player, "ammo_cells1", v))
                    {
                        if (Server.Player.v.weapon <= QItems.IT_LIGHTNING)
                        {
                            Server.Player.v.ammo_cells = v;
                        }
                    }
                }
                else
                {
                    Server.Player.v.ammo_cells = v;
                }
                break;

            case 'p':
                if (Common.GameKind == GameKind.Rogue)
                {
                    if (Progs.SetEdictFieldFloat(Server.Player, "ammo_plasma", v))
                    {
                        if (Server.Player.v.weapon > QItems.IT_LIGHTNING)
                        {
                            Server.Player.v.ammo_cells = v;
                        }
                    }
                }
                break;
            }
        }
예제 #14
0
        /// <summary>
        /// Host_Kick_f
        /// Kicks a user off of the server
        /// </summary>
        private static void Kick_f()
        {
            if (Cmd.Source == cmd_source_t.src_command)
            {
                if (!Server.sv.active)
                {
                    Cmd.ForwardToServer();
                    return;
                }
            }
            else if (Progs.GlobalStruct.deathmatch != 0 && !Host.HostClient.privileged)
            {
                return;
            }

            client_t save     = Host.HostClient;
            bool     byNumber = false;
            int      i;

            if (Cmd.Argc > 2 && Cmd.Argv(1) == "#")
            {
                i = (int)Common.atof(Cmd.Argv(2)) - 1;
                if (i < 0 || i >= Server.svs.maxclients)
                {
                    return;
                }
                if (!Server.svs.clients[i].active)
                {
                    return;
                }

                Host.HostClient = Server.svs.clients[i];
                byNumber        = true;
            }
            else
            {
                for (i = 0; i < Server.svs.maxclients; i++)
                {
                    Host.HostClient = Server.svs.clients[i];
                    if (!Host.HostClient.active)
                    {
                        continue;
                    }
                    if (Common.SameText(Host.HostClient.name, Cmd.Argv(1)))
                    {
                        break;
                    }
                }
            }

            if (i < Server.svs.maxclients)
            {
                string who;
                if (Cmd.Source == cmd_source_t.src_command)
                {
                    if (Client.cls.state == cactive_t.ca_dedicated)
                    {
                        who = "Console";
                    }
                    else
                    {
                        who = Client.Name;
                    }
                }
                else
                {
                    who = save.name;
                }

                // can't kick yourself!
                if (Host.HostClient == save)
                {
                    return;
                }

                string message = null;
                if (Cmd.Argc > 2)
                {
                    message = Common.Parse(Cmd.Args);
                    if (byNumber)
                    {
                        message = message.Substring(1);                  // skip the #
                        message = message.Trim();                        // skip white space
                        message = message.Substring(Cmd.Argv(2).Length); // skip the number
                    }
                    message = message.Trim();
                }
                if (!String.IsNullOrEmpty(message))
                {
                    Server.ClientPrint("Kicked by {0}: {1}\n", who, message);
                }
                else
                {
                    Server.ClientPrint("Kicked by {0}\n", who);
                }
                Server.DropClient(false);
            }

            Host.HostClient = save;
        }