Exemple #1
0
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            s.rwInt(ref type);
            switch ((UniversalType)type)
            {
            case UniversalType.AngleRadians:
            case UniversalType.AngleDegreesFloat:
            case UniversalType.Float:
            {
                float v = 0.0f;
                try { v = (float)value; } catch (NullReferenceException e) { }
                s.rwFloat(ref v);
                value = v;
                break;
            }

            case UniversalType.AngleDegrees:
            case UniversalType.Color:
            case UniversalType.EnumBits:
            case UniversalType.EnumOption:
            case UniversalType.Integer:
            case UniversalType.LinedefTag:
            case UniversalType.LinedefType:
            case UniversalType.SectorEffect:
            case UniversalType.SectorTag:
            case UniversalType.ThingTag:
            case UniversalType.PortalTag:
            {
                int v = 0;
                try { v = (int)value; } catch (NullReferenceException e) { }
                s.rwInt(ref v);
                value = v;
                break;
            }

            case UniversalType.Boolean:
            {
                bool v = false;
                try { v = (bool)value; } catch (NullReferenceException e) { }
                s.rwBool(ref v);
                value = v;
                break;
            }

            case UniversalType.Flat:
            case UniversalType.String:
            case UniversalType.Texture:
            case UniversalType.EnumStrings:
            {
                string v = (string)value;
                s.rwString(ref v);
                value = v;
                break;
            }

            default:
                General.Fail("Unknown field type to read/write!");
                break;
            }
        }
Exemple #2
0
        protected static void ReadWrite(IReadWriteStream s, ref Dictionary <string, bool> flags)
        {
            if (s.IsWriting)
            {
                s.wInt(flags.Count);
                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c;
                s.rInt(out c);

                flags = new Dictionary <string, bool>(c, StringComparer.Ordinal);
                for (int i = 0; i < c; i++)
                {
                    string t;
                    s.rString(out t);
                    bool b;
                    s.rBool(out b);
                    flags.Add(t, b);
                }
            }
        }
Exemple #3
0
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            int c = fields.Count;

            s.rwInt(ref c);

            if (s.IsWriting)
            {
                foreach (KeyValuePair <string, UniValue> f in fields)
                {
                    s.wString(f.Key);
                    f.Value.ReadWrite(s);
                }
            }
            else
            {
                fields = new UniFields(this, c);
                for (int i = 0; i < c; i++)
                {
                    string   t; s.rString(out t);
                    UniValue v = new UniValue(); v.ReadWrite(s);
                    fields.Add(t, v);
                }
            }
        }
Exemple #4
0
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            ReadWrite(s, ref flags);

            s.rwVector3D(ref pos);
            s.rwInt(ref tileindex);
            s.rwInt(ref shade);
            s.rwInt(ref paletteindex);
            s.rwInt(ref clipdistance);
            s.rwInt(ref repeatx);
            s.rwInt(ref repeaty);
            s.rwInt(ref offsetx);
            s.rwInt(ref offsety);
            s.rwInt(ref status);
            s.rwFloat(ref anglerad);

            s.rwInt(ref owner);
            s.rwVector3D(ref vel);

            s.rwInt(ref hitag);
            s.rwInt(ref lotag);
            s.rwInt(ref extra);

            //if(!s.IsWriting) anglerad = Angle2D.BuildToReal(anglebuild);
        }
 // Serialize / deserialize (passive: doesn't record)
 internal void ReadWrite(IReadWriteStream s)
 {
     if (!s.IsWriting)
     {
         BeforePropsChange();
         updateneeded = true;
     }
 }
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            if (s.IsWriting)
            {
                s.wInt(islandvertices.Count);
                for (int i = 0; i < islandvertices.Count; i++)
                {
                    s.wInt(islandvertices[i]);
                }

                s.wInt(vertices.Count);
                for (int i = 0; i < vertices.Count; i++)
                {
                    s.wVector2D(vertices[i]);
                }

                s.wInt(sidedefs.Count);
                for (int i = 0; i < sidedefs.Count; i++)
                {
                    if (sidedefs[i] != null)
                    {
                        s.wInt(sidedefs[i].SerializedIndex);
                    }
                    else
                    {
                        s.wInt(-1);
                    }
                }
            }
            else
            {
                int c;

                s.rInt(out c);
                int[] islandverticeslist = new int[c];
                for (int i = 0; i < c; i++)
                {
                    s.rInt(out islandverticeslist[i]);
                }
                islandvertices = Array.AsReadOnly(islandverticeslist);

                s.rInt(out c);
                Vector2D[] verticeslist = new Vector2D[c];
                for (int i = 0; i < c; i++)
                {
                    s.rVector2D(out verticeslist[i]);
                }
                vertices = Array.AsReadOnly(verticeslist);

                s.rInt(out c);
                sidedefindices = new int[c];
                for (int i = 0; i < c; i++)
                {
                    s.rInt(out sidedefindices[i]);
                }
            }
        }
Exemple #7
0
        // Serialize / deserialize (passive: this doesn't record)
        internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
                updateneeded = true;
            }

            base.ReadWrite(s);

            // villsa
            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c; s.rInt(out c);

                flags = new Dictionary <string, bool>(c);
                for (int i = 0; i < c; i++)
                {
                    string t; s.rString(out t);
                    bool   b; s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref fixedindex);
            s.rwInt(ref floorheight);
            s.rwInt(ref ceilheight);
            s.rwString(ref floortexname);
            s.rwString(ref ceiltexname);
            s.rwLong(ref longfloortexname);
            s.rwLong(ref longceiltexname);
            s.rwInt(ref effect);
            s.rwInt(ref tag);
            s.rwInt(ref brightness);
            // villsa
            if (General.Map.FormatInterface.InDoom64Mode)
            {
                s.rwLight(ref ceilColor);
                s.rwLight(ref flrColor);
                s.rwLight(ref thingColor);
                s.rwLight(ref topColor);
                s.rwLight(ref lwrColor);
            }
        }
Exemple #8
0
        // Serialize / deserialize
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c; s.rInt(out c);

                flags = new Dictionary <string, bool>(c, StringComparer.Ordinal);
                for (int i = 0; i < c; i++)
                {
                    string t; s.rString(out t);
                    bool   b; s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref type);
            s.rwVector3D(ref pos);
            s.rwInt(ref angledoom);
            s.rwInt(ref pitch);            //mxd
            s.rwInt(ref roll);             //mxd
            s.rwDouble(ref scaleX);        //mxd
            s.rwDouble(ref scaleY);        //mxd
            s.rwInt(ref tag);
            s.rwInt(ref action);
            for (int i = 0; i < NUM_ARGS; i++)
            {
                s.rwInt(ref args[i]);
            }

            if (!s.IsWriting)
            {
                anglerad = Angle2D.DoomToReal(angledoom);
                UpdateCache();                 //mxd
            }
        }
        // Serialize / deserialize (passive: this doesn't record)
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            //mxd
            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c;
                s.rInt(out c);

                flags = new Dictionary <string, bool>(c, StringComparer.Ordinal);
                for (int i = 0; i < c; i++)
                {
                    string t;
                    s.rString(out t);
                    bool b;
                    s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref offsetx);
            s.rwInt(ref offsety);
            s.rwString(ref texnamehigh);
            s.rwString(ref texnamemid);
            s.rwString(ref texnamelow);
            s.rwLong(ref longtexnamehigh);
            s.rwLong(ref longtexnamemid);
            s.rwLong(ref longtexnamelow);
        }
Exemple #10
0
        // Serialize / deserialize (passive: this doesn't record)
        // ano - using new keyword to shadow (and get rid of old DB2 warning)
        internal new void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            s.rwInt(ref offsetx);
            s.rwInt(ref offsety);
            s.rwString(ref texnamehigh);
            s.rwString(ref texnamemid);
            s.rwString(ref texnamelow);
            s.rwLong(ref longtexnamehigh);
            s.rwLong(ref longtexnamemid);
            s.rwLong(ref longtexnamelow);
        }
Exemple #11
0
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            s.rwVector2D(ref pos);

            if (s.IsWriting)
            {
                // Let all lines know they need an update
                foreach (Linedef l in linedefs)
                {
                    l.NeedUpdate();
                }
            }
        }
Exemple #12
0
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c; s.rInt(out c);

                flags = new Dictionary <string, bool>(c);
                for (int i = 0; i < c; i++)
                {
                    string t; s.rString(out t);
                    bool   b; s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref type);
            s.rwVector3D(ref pos);
            s.rwFloat(ref angle);
            s.rwInt(ref tag);
            s.rwInt(ref action);
            for (int i = 0; i < NUM_ARGS; i++)
            {
                s.rwInt(ref args[i]);
            }
        }
Exemple #13
0
        // Serialize / deserialize (passive: this doesn't record)
        // ano - using new keyword to shadow (and get rid of old DB2 warning)
        internal new void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
                updateneeded = true;
            }

            base.ReadWrite(s);

            s.rwInt(ref fixedindex);
            s.rwInt(ref floorheight);
            s.rwInt(ref ceilheight);
            s.rwString(ref floortexname);
            s.rwString(ref ceiltexname);
            s.rwLong(ref longfloortexname);
            s.rwLong(ref longceiltexname);
            s.rwInt(ref effect);
            s.rwInt(ref tag);
            s.rwInt(ref brightness);
        }
Exemple #14
0
        // Serialize / deserialize (passive: this doesn't record)
        internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            ReadWrite(s, ref flags);

            s.rwInt(ref offsetx);
            s.rwInt(ref offsety);
            s.rwInt(ref repeatx);
            s.rwInt(ref repeaty);
            s.rwInt(ref tileindex);
            s.rwInt(ref maskedtileindex);
            s.rwInt(ref shade);
            s.rwInt(ref paletteindex);

            s.rwInt(ref hitag);
            s.rwInt(ref lotag);
            s.rwInt(ref extra);
        }
Exemple #15
0
        // Serialize / deserialize
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
            }

            base.ReadWrite(s);

            s.rwVector2D(ref pos);
            s.rwFloat(ref zceiling);           //mxd
            s.rwFloat(ref zfloor);             //mxd

            if (s.IsWriting)
            {
                // Let all lines know they need an update
                foreach (Linedef l in linedefs)
                {
                    l.NeedUpdate();
                }
            }
        }
Exemple #16
0
        // Serialize / deserialize (passive: this doesn't record)
        new internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
                updateneeded = true;
            }

            base.ReadWrite(s);

            //mxd
            if (s.IsWriting)
            {
                s.wInt(flags.Count);

                foreach (KeyValuePair <string, bool> f in flags)
                {
                    s.wString(f.Key);
                    s.wBool(f.Value);
                }
            }
            else
            {
                int c; s.rInt(out c);

                flags = new Dictionary <string, bool>(c, StringComparer.Ordinal);
                for (int i = 0; i < c; i++)
                {
                    string t; s.rString(out t);
                    bool   b; s.rBool(out b);
                    flags.Add(t, b);
                }
            }

            s.rwInt(ref fixedindex);
            s.rwInt(ref floorheight);
            s.rwInt(ref ceilheight);
            s.rwString(ref floortexname);
            s.rwString(ref ceiltexname);
            s.rwLong(ref longfloortexname);
            s.rwLong(ref longceiltexname);
            s.rwInt(ref effect);
            s.rwInt(ref brightness);

            //mxd. (Re)store tags
            if (s.IsWriting)
            {
                s.wInt(tags.Count);
                foreach (int tag in tags)
                {
                    s.wInt(tag);
                }
            }
            else
            {
                int c;
                s.rInt(out c);
                tags = new List <int>(c);
                for (int i = 0; i < c; i++)
                {
                    int t;
                    s.rInt(out t);
                    tags.Add(t);
                }
            }

            //mxd. Slopes
            s.rwFloat(ref flooroffset);
            s.rwVector3D(ref floorslope);
            s.rwFloat(ref ceiloffset);
            s.rwVector3D(ref ceilslope);
        }
Exemple #17
0
        // Serialize / deserialize (passive: this doesn't record)
        internal void ReadWrite(IReadWriteStream s)
        {
            if (!s.IsWriting)
            {
                BeforePropsChange();
                updateneeded             = true;
                ceilingplaneupdateneeded = true;
                floorplaneupdateneeded   = true;
            }

            ReadWrite(s, ref floorflags);
            ReadWrite(s, ref ceilingflags);

            if (s.IsWriting)
            {
                int firstwallindex = (firstwall == null ? -1 : firstwall.Index);
                s.rwInt(ref firstwallindex);
            }
            else
            {
                int firstwallindex = -1;
                s.rwInt(ref firstwallindex);

                if (firstwallindex != -1)
                {
                    foreach (var wall in sidedefs)
                    {
                        if (wall.Index == firstwallindex)
                        {
                            firstwall = wall;
                            break;
                        }
                    }

                    if (firstwall == null)
                    {
                        throw new Exception("Failed to restore FirstWall!");
                    }
                }
            }

            s.rwInt(ref ceilingheight);
            s.rwInt(ref floorheight);

            s.rwInt(ref ceilingtileindex);
            s.rwFloat(ref ceilingslope);
            s.rwInt(ref ceilingshade);
            s.rwInt(ref ceilingpaletteindex);
            s.rwInt(ref ceilingoffsetx);
            s.rwInt(ref ceilingoffsety);

            s.rwInt(ref floortileindex);
            s.rwFloat(ref floorslope);
            s.rwInt(ref floorshade);
            s.rwInt(ref floorpaletteindex);
            s.rwInt(ref flooroffsetx);
            s.rwInt(ref flooroffsety);

            s.rwInt(ref visibility);

            s.rwInt(ref hitag);
            s.rwInt(ref lotag);
            s.rwInt(ref extra);
        }
        // Serialize / deserialize
        internal void ReadWrite(IReadWriteStream s)
        {
            s.rwInt(ref type);
            switch ((UniversalType)type)
            {
            case UniversalType.AngleRadians:
            case UniversalType.AngleDegreesFloat:
            case UniversalType.Float:
            {
                double v = 0.0f;
                //mxd. Seems to work faster this way
                //try { v = (float)value; } catch(NullReferenceException e) { }
                if (value != null)
                {
                    v = (double)value;
                }
                s.rwDouble(ref v);
                value = v;
                break;
            }

            case UniversalType.AngleDegrees:
            case UniversalType.AngleByte:                     //mxd
            case UniversalType.Color:
            case UniversalType.EnumBits:
            case UniversalType.EnumOption:
            case UniversalType.Integer:
            case UniversalType.LinedefTag:
            case UniversalType.LinedefType:
            case UniversalType.SectorEffect:
            case UniversalType.SectorTag:
            case UniversalType.ThingTag:
            case UniversalType.ThingType:
            {
                int v = 0;
                //mxd. Seems to work faster this way
                //try { v = (int)value; } catch(NullReferenceException e) { }
                if (value != null)
                {
                    v = (int)value;
                }
                s.rwInt(ref v);
                value = v;
                break;
            }

            case UniversalType.Boolean:
            {
                bool v = false;
                //mxd. Seems to work faster this way
                //try { v = (bool)value; } catch(NullReferenceException e) { }
                if (value != null)
                {
                    v = (bool)value;
                }
                s.rwBool(ref v);
                value = v;
                break;
            }

            case UniversalType.Flat:
            case UniversalType.String:
            case UniversalType.Texture:
            case UniversalType.EnumStrings:
            case UniversalType.ThingClass:
            {
                string v = (string)value;
                s.rwString(ref v);
                value = v;
                break;
            }

            default:
                General.Fail("Unknown field type to read/write!");
                break;
            }
        }