Beispiel #1
0
        public virtual void Load(VMThreadMarshal input, VMContext context)
        {
            Stack = new List <VMStackFrame>();
            foreach (var item in input.Stack)
            {
                Stack.Add((item is VMRoutingFrameMarshal) ? new VMRoutingFrame(item, context, this) : new VMStackFrame(item, context, this));
            }
            Queue      = new List <VMQueuedAction>();
            QueueDirty = true;
            foreach (var item in input.Queue)
            {
                Queue.Add(new VMQueuedAction(item, context));
            }
            ActiveQueueBlock  = input.ActiveQueueBlock;
            TempRegisters     = input.TempRegisters;
            TempXL            = input.TempXL;
            LastStackExitCode = input.LastStackExitCode;

            BlockingState     = input.BlockingState;
            EODConnection     = input.EODConnection;
            Interrupt         = input.Interrupt;
            ActionUID         = input.ActionUID;
            DialogCooldown    = input.DialogCooldown;
            ScheduleIdleStart = input.ScheduleIdleStart;
        }
Beispiel #2
0
        public VMMarshal Save()
        {
            var ents    = new VMEntityMarshal[Entities.Count];
            var threads = new VMThreadMarshal[Entities.Count];
            var mult    = new List <VMMultitileGroupMarshal>();

            int i = 0;

            foreach (var ent in Entities)
            {
                if (ent is VMAvatar)
                {
                    ents[i] = ((VMAvatar)ent).Save();
                }
                else
                {
                    ents[i] = ((VMGameObject)ent).Save();
                }
                threads[i++] = ent.Thread.Save();
                if (ent.MultitileGroup.BaseObject == ent)
                {
                    mult.Add(ent.MultitileGroup.Save());
                }
            }

            return(new VMMarshal
            {
                Context = Context.Save(),
                Entities = ents,
                Threads = threads,
                MultitileGroups = mult.ToArray(),
                GlobalState = GlobalState,
                ObjectId = ObjectId
            });
        }
Beispiel #3
0
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOv")
            {
                return;
            }

            Context = new VMContextMarshal();
            Context.Deserialize(reader);

            int ents = reader.ReadInt32();

            Entities = new VMEntityMarshal[ents];
            for (int i = 0; i < ents; i++)
            {
                var type = reader.ReadByte();
                var ent  = (type == 1) ? (VMEntityMarshal) new VMAvatarMarshal() : new VMGameObjectMarshal();
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            int thrN = reader.ReadInt32();

            Threads = new VMThreadMarshal[thrN];
            for (int i = 0; i < thrN; i++)
            {
                Threads[i] = new VMThreadMarshal();
                Threads[i].Deserialize(reader);
            }

            int mtgN = reader.ReadInt32();

            MultitileGroups = new VMMultitileGroupMarshal[mtgN];
            for (int i = 0; i < mtgN; i++)
            {
                MultitileGroups[i] = new VMMultitileGroupMarshal();
                MultitileGroups[i].Deserialize(reader);
            }

            int globs = reader.ReadInt32();

            GlobalState = new short[globs];
            for (int i = 0; i < globs; i++)
            {
                GlobalState[i] = reader.ReadInt16();
            }

            ObjectId = reader.ReadInt16();
        }
Beispiel #4
0
        public virtual void Load(VMThreadMarshal input, VMContext context)
        {
            Stack = new List <VMStackFrame>();
            foreach (var item in input.Stack)
            {
                Stack.Add((item is VMRoutingFrameMarshal)? new VMRoutingFrame(item, context, this) : new VMStackFrame(item, context, this));
            }
            Queue = new List <VMQueuedAction>();
            foreach (var item in input.Queue)
            {
                Queue.Add(new VMQueuedAction(item, context));
            }
            TempRegisters     = input.TempRegisters;
            TempXL            = input.TempXL;
            LastStackExitCode = input.LastStackExitCode;

            BlockingDialog = input.BlockingDialog;
            Interrupt      = input.Interrupt;
            ActionUID      = input.ActionUID;
            DialogCooldown = input.DialogCooldown;
        }
Beispiel #5
0
        public void Deserialize(BinaryReader reader)
        {
            if (new string(reader.ReadChars(4)) != "FSOv")
            {
                return;
            }

            Version    = reader.ReadInt32();
            Compressed = reader.ReadBoolean();

            var uReader = reader;

            if (Compressed)
            {
                var length       = reader.ReadInt32();
                var cStream      = new MemoryStream(reader.ReadBytes(length));
                var zipStream    = new GZipStream(cStream, CompressionMode.Decompress);
                var decompStream = new MemoryStream();
                zipStream.CopyTo(decompStream);
                decompStream.Seek(0, SeekOrigin.Begin);
                reader = new BinaryReader(decompStream);
                cStream.Close();
                zipStream.Close();
            }

            Context = new VMContextMarshal(Version);
            Context.Deserialize(reader);

            int ents = reader.ReadInt32();

            Entities = new VMEntityMarshal[ents];
            for (int i = 0; i < ents; i++)
            {
                var type = reader.ReadByte();
                var ent  = (type == 1) ? (VMEntityMarshal) new VMAvatarMarshal(Version) : new VMGameObjectMarshal(Version);
                ent.Deserialize(reader);
                Entities[i] = ent;
            }

            int thrN = reader.ReadInt32();

            Threads = new VMThreadMarshal[thrN];
            for (int i = 0; i < thrN; i++)
            {
                Threads[i] = new VMThreadMarshal(Version);
                Threads[i].Deserialize(reader);
            }

            int mtgN = reader.ReadInt32();

            MultitileGroups = new VMMultitileGroupMarshal[mtgN];
            for (int i = 0; i < mtgN; i++)
            {
                MultitileGroups[i] = new VMMultitileGroupMarshal(Version);
                MultitileGroups[i].Deserialize(reader);
            }

            int globs = reader.ReadInt32();

            GlobalState = new short[globs];
            for (int i = 0; i < globs; i++)
            {
                GlobalState[i] = reader.ReadInt16();
            }

            //assume TSO for now
            PlatformState = new VMTSOLotState(Version);
            PlatformState.Deserialize(reader);

            ObjectId = reader.ReadInt16();

            if (Compressed)
            {
                reader.BaseStream.Close();
            }
        }
Beispiel #6
0
 public VMThread(VMThreadMarshal input, VMContext context, VMEntity entity)
 {
     Context = context;
     Entity  = entity;
     Load(input, context);
 }