Exemple #1
0
        public void Write(OsiWriter writer)
        {
            writer.Write(Index);
            writer.Write(Name);
            writer.Write(SubGoalCombination);

            writer.Write((UInt32)ParentGoals.Count);
            foreach (var goalIndex in ParentGoals)
            {
                writer.Write(goalIndex);
            }

            writer.Write((UInt32)SubGoals.Count);
            foreach (var goalIndex in SubGoals)
            {
                writer.Write(goalIndex);
            }

            writer.Write(Unknown);

            if (writer.MajorVersion > 1 || (writer.MajorVersion == 1 && writer.MinorVersion >= 1))
            {
                writer.WriteList <Call>(InitCalls);
                writer.WriteList <Call>(ExitCalls);
            }
        }
Exemple #2
0
        public void Write(OsiWriter writer)
        {
            writer.Write(Index);
            writer.Write(Name);
            writer.Write(SubGoalCombination);

            writer.WriteList <GoalReference>(ParentGoals);
            writer.WriteList <GoalReference>(SubGoals);

            writer.Write(Flags);

            if (writer.Ver >= OsiVersion.VerAddInitExitCalls)
            {
                writer.WriteList <Call>(InitCalls);
                writer.WriteList <Call>(ExitCalls);
            }
        }
Exemple #3
0
        public void Write(Stream stream, Story story)
        {
            using (Writer = new OsiWriter(stream))
            {
                Writer.MajorVersion = story.MajorVersion;
                Writer.MinorVersion = story.MinorVersion;

                var header = new OsirisHeader();
                header.Version      = "Osiris save file dd. 02/10/15 12:44:13. Version 1.5.";
                header.MajorVersion = story.MajorVersion;
                header.MinorVersion = story.MinorVersion;
                header.BigEndian    = false;
                header.Unused       = 0;
                // Debug flags used in D:OS EE
                header.DebugFlags = 0x000CA010;
                header.Write(Writer);

                if (Writer.MajorVersion > 1 || (Writer.MajorVersion == 1 && Writer.MinorVersion > 7))
                {
                    var msg = String.Format(
                        "Osiris version v{0}.{1} unsupported; this tool supports versions up to v1.7.",
                        Writer.MajorVersion, Writer.MinorVersion
                        );
                    throw new InvalidDataException(msg);
                }

                if (Writer.MajorVersion > 1 || (Writer.MajorVersion == 1 && Writer.MinorVersion >= 4))
                {
                    Writer.Scramble = 0xAD;
                }


                if (Writer.MajorVersion > 1 || (Writer.MajorVersion == 1 && Writer.MinorVersion >= 5))
                {
                    WriteTypes(story.Types);
                }

                Writer.WriteList(story.DivObjects);
                Writer.WriteList(story.Functions);
                WriteNodes(story.Nodes);
                WriteAdapters(story.Adapters);
                WriteDatabases(story.Databases);
                WriteGoals(story.Goals);
                Writer.WriteList(story.GlobalActions);
            }
        }
Exemple #4
0
        public override void Write(OsiWriter writer)
        {
            base.Write(writer);
            writer.WriteList <Call>(Calls);

            writer.Write((byte)Variables.Count);
            foreach (var variable in Variables)
            {
                writer.Write((byte)1);
                variable.Write(writer);
            }

            writer.Write(Line);
            if (writer.Ver >= OsiVersion.VerAddQuery)
            {
                writer.Write(IsQuery);
            }
        }
Exemple #5
0
        public override void Write(OsiWriter writer)
        {
            base.Write(writer);
            writer.WriteList <Call>(Calls);

            writer.Write((byte)Variables.Count);
            foreach (var variable in Variables)
            {
                writer.Write((byte)1);
                variable.Write(writer);
            }

            writer.Write(Line);
            if (writer.MajorVersion > 1 || (writer.MajorVersion == 1 && writer.MinorVersion >= 6))
            {
                writer.Write(IsQuery);
            }
        }
Exemple #6
0
        public void Write(Stream stream, Story story)
        {
            using (Writer = new OsiWriter(stream))
            {
                foreach (var node in story.Nodes)
                {
                    node.Value.PreSave(story);
                }

                Writer.MajorVersion = story.MajorVersion;
                Writer.MinorVersion = story.MinorVersion;

                var header = new SaveFileHeader();
                if (Writer.Ver >= OsiVersion.VerExternalStringTable)
                {
                    header.Version = "Osiris save file dd. 03/30/17 07:28:20. Version 1.8.";
                }
                else
                {
                    header.Version = "Osiris save file dd. 02/10/15 12:44:13. Version 1.5.";
                }
                header.MajorVersion = story.MajorVersion;
                header.MinorVersion = story.MinorVersion;
                header.BigEndian    = false;
                header.Unused       = 0;
                // Debug flags used in D:OS EE and D:OS 2
                header.DebugFlags = 0x000C10A0;
                header.Write(Writer);

                if (Writer.Ver > OsiVersion.VerLastSupported)
                {
                    var msg = String.Format(
                        "Osiris version v{0}.{1} unsupported; this tool supports saving up to version 1.11.",
                        Writer.MajorVersion, Writer.MinorVersion
                        );
                    throw new InvalidDataException(msg);
                }

                if (Writer.Ver >= OsiVersion.VerScramble)
                {
                    Writer.Scramble = 0xAD;
                }

                if (Writer.Ver >= OsiVersion.VerAddTypeMap)
                {
                    // Don't export builtin types, only externally declared ones
                    var types = story.Types.Values.Where(t => !t.IsBuiltin).ToList();
                    WriteTypes(types);
                }

                // TODO: regenerate string table?
                if (Writer.Ver >= OsiVersion.VerExternalStringTable && Writer.Ver < OsiVersion.VerRemoveExternalStringTable)
                {
                    WriteStrings(story.ExternalStringTable);
                }

                Writer.WriteList(story.DivObjects);
                Writer.WriteList(story.Functions);
                WriteNodes(story.Nodes);
                WriteAdapters(story.Adapters);
                WriteDatabases(story.Databases);
                WriteGoals(story.Goals);
                Writer.WriteList(story.GlobalActions);

                foreach (var node in story.Nodes)
                {
                    node.Value.PostSave(story);
                }
            }
        }
Exemple #7
0
 public void Write(OsiWriter writer)
 {
     Parameters.Write(writer);
     writer.WriteList <Fact>(Facts);
 }
Exemple #8
0
 public override void Write(OsiWriter writer)
 {
     base.Write(writer);
     writer.WriteList <NodeEntryItem>(ReferencedBy);
 }