Lokai

Moderator
I am attaching this to a musical instrument in the game:

Code:
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Targeting;
using System.Text.RegularExpressions;
using Server.Engines.XmlSpawner2;


namespace Server
{
    public class XmlMusic : XmlAttachment
    {
        private Queue m_PlayList;

        [CommandProperty(AccessLevel.GameMaster)]
        public Queue PlayList { get { return m_PlayList; } set { m_PlayList = value; } }

        private bool m_FilterMusic;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool FilterMusic { get { return m_FilterMusic; } set { m_FilterMusic = value; } }

        private bool m_Playing;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Playing { get { return m_Playing; } set { m_Playing = value; } }

        private string m_Song;

        [CommandProperty(AccessLevel.GameMaster)]
        public string Song { get { return m_Song; } set { m_Song = value; } }

        public XmlMusic(ASerial serial)
            : base(serial)
        {
        }

        [Attachable]
        public XmlMusic()
            : this(new Queue())
        {
        }

        [Attachable]
        public XmlMusic(Queue playlist)
        {
            m_FilterMusic = false;
            m_Playing = false;
            m_PlayList = playlist;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(0); // Version

            writer.Write(m_FilterMusic);
            writer.Write(m_Song);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                    {
                        m_FilterMusic = reader.ReadBool();
                        m_Song = reader.ReadString();
                        m_Playing = false;
                        m_PlayList = new Queue();
                        break;
                    }
            }
        }
    }
}

I get the following error during restart:

Code:
World: Loading...

Error deserializing attachments Server.XmlMusic.
Missing a serial constructor?


XmlSpawner2 Attachment Error:
Error deserializing particular attachments.
Generating report...done

The text file generated gives the same error.

Any idea? @tass23

EDIT ****

I just edited the code. Added "[Attachable]" to constructors, still getting the same error.
 
Last edited:
I am attaching this to a musical instrument in the game:

Code:
using System;
using Server;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Targeting;
using System.Text.RegularExpressions;
using Server.Engines.XmlSpawner2;


namespace Server
{
    public class XmlMusic : XmlAttachment
    {
        private Queue m_PlayList;

        [CommandProperty(AccessLevel.GameMaster)]
        public Queue PlayList { get { return m_PlayList; } set { m_PlayList = value; } }

        private bool m_FilterMusic;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool FilterMusic { get { return m_FilterMusic; } set { m_FilterMusic = value; } }

        private bool m_Playing;

        [CommandProperty(AccessLevel.GameMaster)]
        public bool Playing { get { return m_Playing; } set { m_Playing = value; } }

        private string m_Song;

        [CommandProperty(AccessLevel.GameMaster)]
        public string Song { get { return m_Song; } set { m_Song = value; } }

        public XmlMusic(ASerial serial)
            : base(serial)
        {
        }

        [Attachable]
        public XmlMusic()
            : this(new Queue())
        {
        }

        [Attachable]
        public XmlMusic(Queue playlist)
        {
            m_FilterMusic = false;
            m_Playing = false;
            m_PlayList = playlist;
        }

        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write(0); // Version

            writer.Write(m_FilterMusic);
            writer.Write(m_Song);
        }

        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 0:
                    {
                        m_FilterMusic = reader.ReadBool();
                        m_Song = reader.ReadString();
                        m_Playing = false;
                        m_PlayList = new Queue();
                        break;
                    }
            }
        }
    }
}

I get the following error during restart:

Code:
World: Loading...

Error deserializing attachments Server.XmlMusic.
Missing a serial constructor?


XmlSpawner2 Attachment Error:
Error deserializing particular attachments.
Generating report...done

The text file generated gives the same error.

Any idea? @tass23

EDIT ****

I just edited the code. Added "[Attachable]" to constructors, still getting the same error.
I have never seen that kind of error before with anything Xmlspawner related. It shouldn't matter, but just to fill in the blanks...how are you attaching it (QuestNPC, Xmlspawner, script, etc?)
 
Like this:

Code:
            XmlMusic xm = (XmlMusic)XmlAttach.FindAttachment(instrument, typeof(XmlMusic));
            if (xm == null)
            {
                XmlAttach.AttachTo(instrument, new XmlMusic());
            }
 
Sorry, I missed this before...shouldn't ASerial serial, actually be Serial serial in the constructor?
 
Shooting from the hip. I'll take a look at some code tomorrow, and see if we can't figure this out properly, dude ☺

EDIT:
I saw your Music system post. Is it all working now?
 
Last edited:

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back