Example #1
0
        /// <summary>
        /// Host_FindMaxClients
        /// </summary>
        private void FindMaxClients( )
        {
            var svs = Server.svs;
            var cls = Client.cls;

            svs.maxclients = 1;

            var i = CommandLine.CheckParm("-dedicated");

            if (i > 0)
            {
                cls.state = cactive_t.ca_dedicated;
                if (i != (CommandLine.Argc - 1))
                {
                    svs.maxclients = MathLib.atoi(CommandLine.Argv(i + 1));
                }
                else
                {
                    svs.maxclients = 8;
                }
            }
            else
            {
                cls.state = cactive_t.ca_disconnected;
            }

            i = CommandLine.CheckParm("-listen");
            if (i > 0)
            {
                if (cls.state == cactive_t.ca_dedicated)
                {
                    Utilities.Error("Only one of -dedicated or -listen can be specified");
                }
                if (i != (CommandLine.Argc - 1))
                {
                    svs.maxclients = MathLib.atoi(CommandLine.Argv(i + 1));
                }
                else
                {
                    svs.maxclients = 8;
                }
            }
            if (svs.maxclients < 1)
            {
                svs.maxclients = 8;
            }
            else if (svs.maxclients > QDef.MAX_SCOREBOARD)
            {
                svs.maxclients = QDef.MAX_SCOREBOARD;
            }

            svs.maxclientslimit = svs.maxclients;
            if (svs.maxclientslimit < 4)
            {
                svs.maxclientslimit = 4;
            }
            svs.clients = new client_t[svs.maxclientslimit]; // Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients");
            for (i = 0; i < svs.clients.Length; i++)
            {
                svs.clients[i] = new client_t( );
            }

            if (svs.maxclients > 1)
            {
                CVars.Set("deathmatch", 1);
            }
            else
            {
                CVars.Set("deathmatch", 0);
            }
        }