예제 #1
0
        public static void SV_Map(Boolean attractloop, String levelstring, Boolean loadgame)
        {
            Int32  l;
            String level, ch, spawnpoint;
            var    pos = 0;

            sv.loadgame    = loadgame;
            sv.attractloop = attractloop;
            if (sv.state == Defines.ss_dead && !sv.loadgame)
            {
                SV_InitGame();
            }
            level = levelstring;
            var c = level.IndexOf('+');

            if (c != -1)
            {
                Cvar.Set("nextserver", "gamemap \\\"" + level.Substring(c + 1) + "\\\"");
                level = level.Substring(0, c);
            }
            else
            {
                Cvar.Set("nextserver", "");
            }

            if (firstmap.Length == 0)
            {
                if (!levelstring.EndsWith(".cin") && !levelstring.EndsWith(".pcx") && !levelstring.EndsWith(".dm2"))
                {
                    pos      = levelstring.IndexOf('+');
                    firstmap = levelstring.Substring(pos + 1);
                }
            }

            if (Cvar.VariableValue("coop") != 0 && level.Equals("victory.pcx"))
            {
                Cvar.Set("nextserver", "gamemap \\\"*" + firstmap + "\\\"");
            }
            pos = level.IndexOf('$');
            if (pos != -1)
            {
                spawnpoint = level.Substring(pos + 1);
                level      = level.Substring(0, pos);
            }
            else
            {
                spawnpoint = "";
            }
            if (level[0] == '*')
            {
                level = level.Substring(1);
            }
            l = level.Length;
            if (l > 4 && level.EndsWith(".cin"))
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SpawnServer(level, spawnpoint, Defines.ss_cinematic, attractloop, loadgame);
            }
            else if (l > 4 && level.EndsWith(".dm2"))
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SpawnServer(level, spawnpoint, Defines.ss_demo, attractloop, loadgame);
            }
            else if (l > 4 && level.EndsWith(".pcx"))
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SpawnServer(level, spawnpoint, Defines.ss_pic, attractloop, loadgame);
            }
            else
            {
                SCR.BeginLoadingPlaque();
                SV_SEND.SV_BroadcastCommand("changing\\n");
                SV_SEND.SV_SendClientMessages();
                SV_SpawnServer(level, spawnpoint, Defines.ss_game, attractloop, loadgame);
                Cbuf.CopyToDefer();
            }

            SV_SEND.SV_BroadcastCommand("reconnect\\n");
        }
예제 #2
0
        /**
         * SV_InitGame.
         *
         * A brand new game has been started.
         */
        public static void SV_InitGame()
        {
            int     i;
            edict_t ent;

            //char idmaster[32];
            string idmaster;

            if (SV_INIT.svs.initialized)
            {
                // cause any connected clients to reconnect
                SV_MAIN.SV_Shutdown("Server restarted\n", true);
            }
            else
            {
                // make sure the client is down
                Cl.Drop();
                SCR.BeginLoadingPlaque();
            }

            // get any latched variable changes (maxclients, etc)
            Cvar.GetLatchedVars();

            SV_INIT.svs.initialized = true;

            if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0)
            {
                Com.Printf("Deathmatch and Coop both set, disabling Coop\n");
                Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
            }

            // dedicated servers are can't be single player and are usually DM
            // so unless they explicity set coop, force it to deathmatch
            if (Globals.dedicated.value != 0)
            {
                if (0 == Cvar.VariableValue("coop"))
                {
                    Cvar.FullSet("deathmatch", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
            }

            // init clients
            if (Cvar.VariableValue("deathmatch") != 0)
            {
                if (SV_MAIN.maxclients.value <= 1)
                {
                    Cvar.FullSet("maxclients", "8", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
                else if (SV_MAIN.maxclients.value > Defines.MAX_CLIENTS)
                {
                    Cvar.FullSet("maxclients", "" + Defines.MAX_CLIENTS, Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
            }
            else if (Cvar.VariableValue("coop") != 0)
            {
                if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4)
                {
                    Cvar.FullSet("maxclients", "4", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
            }
            else             // non-deathmatch, non-coop is one player
            {
                Cvar.FullSet("maxclients", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
            }

            SV_INIT.svs.spawncount = Lib.rand();
            SV_INIT.svs.clients    = new client_t[(int)SV_MAIN.maxclients.value];

            for (var n = 0; n < SV_INIT.svs.clients.Length; n++)
            {
                SV_INIT.svs.clients[n]             = new();
                SV_INIT.svs.clients[n].serverindex = n;
            }

            SV_INIT.svs.num_client_entities = (int)SV_MAIN.maxclients.value * Defines.UPDATE_BACKUP * 64;             //ok.

            SV_INIT.svs.client_entities = new entity_state_t[SV_INIT.svs.num_client_entities];

            for (var n = 0; n < SV_INIT.svs.client_entities.Length; n++)
            {
                SV_INIT.svs.client_entities[n] = new(null);
            }

            // init network stuff
            NET.ConfigServer(SV_MAIN.maxclients.value > 1);

            // heartbeats will always be sent to the id master
            SV_INIT.svs.last_heartbeat = -99999;             // send immediately
            idmaster = "192.246.40.37:" + Defines.PORT_MASTER;
            NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]);

            // init game
            SV_GAME.SV_InitGameProgs();

            for (i = 0; i < SV_MAIN.maxclients.value; i++)
            {
                ent = GameBase.g_edicts[i + 1];
                SV_INIT.svs.clients[i].edict   = ent;
                SV_INIT.svs.clients[i].lastcmd = new();
            }
        }
예제 #3
0
        public static void SV_InitGame( )
        {
            Int32   i;
            edict_t ent;
            String  idmaster;

            if (svs.initialized)
            {
                SV_MAIN.SV_Shutdown("Server restarted\\n", true);
            }
            else
            {
                CL.Drop();
                SCR.BeginLoadingPlaque();
            }

            Cvar.GetLatchedVars();
            svs.initialized = true;
            if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0)
            {
                Com.Printf("Deathmatch and Coop both set, disabling Coop\\n");
                Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
            }

            if (Globals.dedicated.value != 0)
            {
                if (0 == Cvar.VariableValue("coop"))
                {
                    Cvar.FullSet("deathmatch", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
            }

            if (Cvar.VariableValue("deathmatch") != 0)
            {
                if (SV_MAIN.maxclients.value <= 1)
                {
                    Cvar.FullSet("maxclients", "8", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
                else if (SV_MAIN.maxclients.value > Defines.MAX_CLIENTS)
                {
                    Cvar.FullSet("maxclients", "" + Defines.MAX_CLIENTS, Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
            }
            else if (Cvar.VariableValue("coop") != 0)
            {
                if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4)
                {
                    Cvar.FullSet("maxclients", "4", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
                }
            }
            else
            {
                Cvar.FullSet("maxclients", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
            }

            svs.spawncount = Lib.Rand();
            svs.clients    = new client_t[( Int32 )SV_MAIN.maxclients.value];
            for (var n = 0; n < svs.clients.Length; n++)
            {
                svs.clients[n]             = new client_t();
                svs.clients[n].serverindex = n;
            }

            svs.num_client_entities = (( Int32 )SV_MAIN.maxclients.value) * Defines.UPDATE_BACKUP * 64;
            svs.client_entities     = new entity_state_t[svs.num_client_entities];
            for (var n = 0; n < svs.client_entities.Length; n++)
            {
                svs.client_entities[n] = new entity_state_t(null);
            }
            NET.Config((SV_MAIN.maxclients.value > 1));
            svs.last_heartbeat = -99999;
            idmaster           = "192.246.40.37:" + Defines.PORT_MASTER;
            NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]);
            SV_GAME.SV_InitGameProgs();
            for (i = 0; i < SV_MAIN.maxclients.value; i++)
            {
                ent = GameBase.g_edicts[i + 1];
                svs.clients[i].edict   = ent;
                svs.clients[i].lastcmd = new usercmd_t();
            }
        }