Beispiel #1
0
            public void Save(DoomGame game, string path)
            {
                var options = game.World.Options;

                this.writer.Write((byte)options.Skill);
                this.writer.Write((byte)options.Episode);
                this.writer.Write((byte)options.Map);

                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    this.writer.Write(options.Players[i].InGame ? (byte)1 : (byte)0);
                }

                this.writer.Write((byte)(game.World.LevelTime >> 16));
                this.writer.Write((byte)(game.World.LevelTime >> 8));
                this.writer.Write((byte)(game.World.LevelTime));

                this.ArchivePlayers(game.World);
                this.ArchiveWorld(game.World);
                this.ArchiveThinkers(game.World);
                this.ArchiveSpecials(game.World);

                this.writer.Write((byte)0x1d);

                using (var writer = DoomApplication.Instance.FileSystem.Write(path))
                {
                    writer.Write(((MemoryStream)this.writer.BaseStream).GetBuffer(), 0, (int)this.writer.BaseStream.Length);
                }
            }
Beispiel #2
0
            public void Save(DoomGame game, string path)
            {
                var options = game.World.Options;

                this.writer.Write((byte)options.Skill);
                this.writer.Write((byte)options.Episode);
                this.writer.Write((byte)options.Map);

                this.writer.Write(game.World.LevelTime);

                game.World.WorldEntity.Serialize(this.writer);
                this.writer.Write(game.World.Entities.Count);
                game.World.Entities.ForEach(entity => entity.Serialize(this.writer));

                this.ArchivePlayers(game.World);
                this.ArchiveWorld(game.World);
                this.ArchiveThinkers(game.World);
                this.ArchiveSpecials(game.World);

                this.writer.Write((byte)0x1d);

                using (var writer = DoomApplication.Instance.FileSystem.Write(path))
                {
                    writer.Write(((MemoryStream)this.writer.BaseStream).GetBuffer(), 0, (int)this.writer.BaseStream.Length);
                }
            }
Beispiel #3
0
        public static void Load(DoomGame game, string path)
        {
            var options = game.Options;

            game.InitNew(options.Skill, options.Episode, options.Map);

            var lg = new LoadGame(DoomApplication.Instance.FileSystem.Read(path));

            lg.Load(game);
        }
Beispiel #4
0
            public void Load(DoomGame game)
            {
                var options = game.World.Options;

                options.Skill   = (GameSkill)this.reader.ReadByte();
                options.Episode = this.reader.ReadByte();
                options.Map     = this.reader.ReadByte();

                game.InitNew(options.Skill, options.Episode, options.Map);

                var levelTime = this.reader.ReadInt32();

                game.World.WorldEntity = Entity.Deserialize(game.World, this.reader);

                var numEntities = this.reader.ReadInt32();

                for (var i = 0; i < numEntities; i++)
                {
                    game.World.Entities.Add(Entity.Deserialize(game.World, this.reader));
                }

                this.UnArchivePlayers(game.World);
                this.UnArchiveWorld(game.World);
                this.UnArchiveThinkers(game.World);
                this.UnArchiveSpecials(game.World);

                var test = this.reader.ReadByte();

                this.reader.BaseStream.Position--;

                if (test != 0x1d)
                {
                    throw new Exception("Bad savegame!");
                }

                game.World.LevelTime = levelTime;

                options.Sound.SetListener(game.World.Options.Player.Mobj);
            }
Beispiel #5
0
            public void Load(DoomGame game)
            {
                var options = game.World.Options;

                options.Skill   = (GameSkill)this.reader.ReadByte();
                options.Episode = this.reader.ReadByte();
                options.Map     = this.reader.ReadByte();

                for (var i = 0; i < Player.MaxPlayerCount; i++)
                {
                    options.Players[i].InGame = this.reader.ReadByte() != 0;
                }

                game.InitNew(options.Skill, options.Episode, options.Map);

                var a         = this.reader.ReadByte();
                var b         = this.reader.ReadByte();
                var c         = this.reader.ReadByte();
                var levelTime = (a << 16) + (b << 8) + c;

                this.UnArchivePlayers(game.World);
                this.UnArchiveWorld(game.World);
                this.UnArchiveThinkers(game.World);
                this.UnArchiveSpecials(game.World);

                var test = this.reader.ReadByte();

                this.reader.BaseStream.Position--;

                if (test != 0x1d)
                {
                    throw new Exception("Bad savegame!");
                }

                game.World.LevelTime = levelTime;

                options.Sound.SetListener(game.World.ConsolePlayer.Mobj);
            }
Beispiel #6
0
        public static void Save(DoomGame game, string description, string path)
        {
            var sg = new SaveGame(description);

            sg.Save(game, path);
        }