WritePSSGString() public method

public WritePSSGString ( string str ) : void
str string
return void
Ejemplo n.º 1
0
        public static void SaveToPssg(PssgBinaryWriter writer)
        {
            // Update Ids to make sequential, and Unique
            int currentId     = 0;
            int currentAttrId = 0;

            // Minimizing the attributes to unique names only seems to crash the game
            //Dictionary<string, int> unique = new Dictionary<string, int>();

            foreach (KeyValuePair <string, Node> entry in entries)
            {
                if (entry.Value.Id > 0)
                {
                    entry.Value.Id = ++currentId;
                    writer.Write(entry.Value.Id);
                    writer.WritePSSGString((string)entry.Key);

                    int pos            = (int)writer.BaseStream.Position;
                    int attributeCount = 0;
                    writer.Write(0); // attributeCount

                    foreach (Attribute attrEntry in entry.Value.Attributes)
                    {
                        if (attrEntry.Id > 0)
                        {
                            attrEntry.Id = ++currentAttrId;
                            writer.Write(attrEntry.Id);
                            writer.WritePSSGString(attrEntry.Name);
                            ++attributeCount;
                        }
                    }

                    writer.Seek(pos, SeekOrigin.Begin);
                    writer.Write(attributeCount);
                    writer.Seek(0, SeekOrigin.End);
                }
            }
        }
Ejemplo n.º 2
0
        public static void SaveToPssg(PssgBinaryWriter writer)
        {
            // Update Ids to make sequential, and Unique
            int currentId = 0;
            int currentAttrId = 0;
            // Minimizing the attributes to unique names only seems to crash the game
            //Dictionary<string, int> unique = new Dictionary<string, int>();

            foreach (KeyValuePair<string, Node> entry in entries)
            {
                if (entry.Value.Id > 0)
                {
                    entry.Value.Id = ++currentId;
                    writer.Write(entry.Value.Id);
                    writer.WritePSSGString((string)entry.Key);

                    int pos = (int)writer.BaseStream.Position;
                    int attributeCount = 0;
                    writer.Write(0); // attributeCount

                    foreach (Attribute attrEntry in entry.Value.Attributes)
                    {
                        if (attrEntry.Id > 0)
                        {
                            attrEntry.Id = ++currentAttrId;
                            writer.Write(attrEntry.Id);
                            writer.WritePSSGString(attrEntry.Name);
                            ++attributeCount;
                        }
                    }

                    writer.Seek(pos, SeekOrigin.Begin);
                    writer.Write(attributeCount);
                    writer.Seek(0, SeekOrigin.End);
                }
            }
        }