Пример #1
0
        public static void SV_GameMap_f( )
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("USAGE: gamemap <map>\\n");
                return;
            }

            Com.DPrintf("SV_GameMap(" + Cmd.Argv(1) + ")\\n");
            FS.CreatePath(FS.Gamedir() + "/save/current/");
            var map = Cmd.Argv(1);

            if (map[0] == '*')
            {
                SV_WipeSavegame("current");
            }
            else
            {
                if (SV_INIT.sv.state == Defines.ss_game)
                {
                    client_t  cl;
                    Boolean[] savedInuse = new Boolean[( Int32 )SV_MAIN.maxclients.value];
                    for (var i = 0; i < SV_MAIN.maxclients.value; i++)
                    {
                        cl             = SV_INIT.svs.clients[i];
                        savedInuse[i]  = cl.edict.inuse;
                        cl.edict.inuse = false;
                    }

                    SV_WriteLevelFile();
                    for (var i = 0; i < SV_MAIN.maxclients.value; i++)
                    {
                        cl             = SV_INIT.svs.clients[i];
                        cl.edict.inuse = savedInuse[i];
                    }

                    savedInuse = null;
                }
            }

            SV_INIT.SV_Map(false, Cmd.Argv(1), false);
            SV_INIT.svs.mapcmd = Cmd.Argv(1);
            if (0 == Globals.dedicated.value)
            {
                SV_WriteServerFile(true);
                SV_CopySaveGame("current", "save0");
            }
        }
Пример #2
0
        public static void SV_Loadgame_f( )
        {
            if (Cmd.Argc() != 2)
            {
                Com.Printf("USAGE: loadgame <directory>\\n");
                return;
            }

            Com.Printf("Loading game...\\n");
            var dir = Cmd.Argv(1);

            if ((dir.IndexOf("..") > -1) || (dir.IndexOf("/") > -1) || (dir.IndexOf("\\\\") > -1))
            {
                Com.Printf("Bad savedir.\\n");
            }

            var       name = FS.Gamedir() + "/save/" + Cmd.Argv(1) + "/server.ssv";
            QuakeFile f;

            try
            {
                f = new QuakeFile(name, FileAccess.Read);
            }
            catch (FileNotFoundException e)
            {
                Com.Printf("No such savegame: " + name + "\\n");
                return;
            }

            try
            {
                f.Dispose();
            }
            catch (IOException e1)
            {
                e1.PrintStackTrace();
            }

            SV_CopySaveGame(Cmd.Argv(1), "current");
            SV_ReadServerFile();
            SV_INIT.sv.state = Defines.ss_dead;
            SV_INIT.SV_Map(false, SV_INIT.svs.mapcmd, true);
        }
Пример #3
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);
            }
        }
Пример #4
0
        public static void SV_ReadServerFile( )
        {
            String filename = "", name = "", string_renamed, mapcmd;

            try
            {
                QuakeFile f;
                mapcmd = "";
                Com.DPrintf("SV_ReadServerFile()\\n");
                filename = FS.Gamedir() + "/save/current/server.ssv";
                f        = new QuakeFile(filename, FileAccess.Read);
                f.ReadString();
                mapcmd = f.ReadString();
                while (true)
                {
                    name = f.ReadString();
                    if (name == null)
                    {
                        break;
                    }
                    string_renamed = f.ReadString();
                    Com.DPrintf("Set " + name + " = " + string_renamed + "\\n");
                    Cvar.ForceSet(name, string_renamed);
                }

                f.Close();
                SV_INIT.SV_InitGame();
                SV_INIT.svs.mapcmd = mapcmd;
                filename           = FS.Gamedir() + "/save/current/game.ssv";
                GameSave.ReadGame(filename);
            }
            catch (Exception e)
            {
                Com.Printf("Couldn't read file " + filename + "\\n");
                e.PrintStackTrace();
            }
        }
Пример #5
0
 public static void SV_DemoMap_f( )
 {
     SV_INIT.SV_Map(true, Cmd.Argv(1), false);
 }