Exemple #1
0
        public static void SV_CheckForSavegame( )
        {
            String     name;
            FileStream f;
            Int32      i;

            if (SV_MAIN.sv_noreload.value != 0)
            {
                return;
            }
            if (Cvar.VariableValue("deathmatch") != 0)
            {
                return;
            }
            name = FS.Gamedir() + "/save/current/" + sv.name + ".sav";
            try
            {
                f = File.OpenRead(name);
            }
            catch (Exception e)
            {
                return;
            }

            try
            {
                f.Close();
            }
            catch (Exception e1)
            {
                e1.PrintStackTrace();
            }

            SV_WORLD.SV_ClearWorld();
            SV_CCMDS.SV_ReadLevelFile();
            if (!sv.loadgame)
            {
                Int32 previousState;
                previousState = sv.state;
                sv.state      = Defines.ss_loading;
                for (i = 0; i < 100; i++)
                {
                    GameBase.G_RunFrame();
                }
                sv.state = previousState;
            }
        }
Exemple #2
0
        public static void PF_setmodel(edict_t ent, string name)
        {
            int      i;
            cmodel_t mod;

            if (name == null)
            {
                Com.Error(Defines.ERR_DROP, "PF_setmodel: NULL");
            }
            i = SV_INIT.SV_ModelIndex(name);
            ent.s.modelindex = i;
            if (name.StartsWith("*"))
            {
                mod = CM.InlineModel(name);
                Math3D.VectorCopy(mod.mins, ent.mins);
                Math3D.VectorCopy(mod.maxs, ent.maxs);
                SV_WORLD.SV_LinkEdict(ent);
            }
        }
Exemple #3
0
 static SV_WORLD()
 {
     SV_WORLD.InitNodes();
 }
Exemple #4
0
        public static void SV_SpawnServer(String server, String spawnpoint, Int32 serverstate, Boolean attractloop, Boolean loadgame)
        {
            Int32 i;
            var   checksum = 0;

            if (attractloop)
            {
                Cvar.Set("paused", "0");
            }
            Com.Printf("------- Server Initialization -------\\n");
            Com.DPrintf("SpawnServer: " + server + "\\n");
            if (sv.demofile != null)
            {
                try
                {
                    sv.demofile.Close();
                }
                catch (Exception e)
                {
                }
            }

            svs.spawncount++;
            sv.state             = Defines.ss_dead;
            Globals.server_state = sv.state;
            sv             = new server_t();
            svs.realtime   = 0;
            sv.loadgame    = loadgame;
            sv.attractloop = attractloop;
            sv.configstrings[Defines.CS_NAME] = server;
            if (Cvar.VariableValue("deathmatch") != 0)
            {
                sv.configstrings[Defines.CS_AIRACCEL] = "" + SV_MAIN.sv_airaccelerate.value;
                PMove.pm_airaccelerate = SV_MAIN.sv_airaccelerate.value;
            }
            else
            {
                sv.configstrings[Defines.CS_AIRACCEL] = "0";
                PMove.pm_airaccelerate = 0;
            }

            SZ.Init(sv.multicast, sv.multicast_buf, sv.multicast_buf.Length);
            sv.name = server;
            for (i = 0; i < SV_MAIN.maxclients.value; i++)
            {
                if (svs.clients[i].state > Defines.cs_connected)
                {
                    svs.clients[i].state = Defines.cs_connected;
                }
                svs.clients[i].lastframe = -1;
            }

            sv.time = 1000;
            sv.name = server;
            sv.configstrings[Defines.CS_NAME] = server;
            Int32[] iw = new[] { checksum };
            if (serverstate != Defines.ss_game)
            {
                sv.models[1] = CM.CM_LoadMap("", false, iw);
            }
            else
            {
                sv.configstrings[Defines.CS_MODELS + 1] = "maps/" + server + ".bsp";
                sv.models[1] = CM.CM_LoadMap(sv.configstrings[Defines.CS_MODELS + 1], false, iw);
            }

            checksum = iw[0];
            sv.configstrings[Defines.CS_MAPCHECKSUM] = "" + checksum;
            SV_WORLD.SV_ClearWorld();
            for (i = 1; i < CM.CM_NumInlineModels(); i++)
            {
                sv.configstrings[Defines.CS_MODELS + 1 + i] = "*" + i;
                sv.models[i + 1] = CM.InlineModel(sv.configstrings[Defines.CS_MODELS + 1 + i]);
            }

            sv.state             = Defines.ss_loading;
            Globals.server_state = sv.state;
            GameSpawn.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint);
            GameBase.G_RunFrame();
            GameBase.G_RunFrame();
            sv.state             = serverstate;
            Globals.server_state = sv.state;
            SV_CreateBaseline();
            SV_CheckForSavegame();
            Cvar.FullSet("mapname", sv.name, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET);
        }