Beispiel #1
0
        private void WriteHeader(ref Stream s)
        {
            HeaderStruct header = new HeaderStruct();

                header.pathNodeCount = Nodes.Count;
                header.version = 2;

                BinaryWriter bw = new BinaryWriter(s);
                bw.Write(System.Text.Encoding.ASCII.GetBytes("EQEMUPATH"));

                bw.Write(Functions.StructToByteArray(header));
        }
Beispiel #2
0
        private void ReadNodes(ref Stream s, HeaderStruct header)
        {
            BinaryReader br = new BinaryReader(s);

                int size = Marshal.SizeOf(typeof(NodeStruct));
                int nsize = Marshal.SizeOf(typeof(NeighborStruct));

                byte[] buffer = new byte[size];
                byte[] neighbor = new byte[nsize];

                List<Neighbor> nList;
                Node n;
                for (int i = 0; i < header.pathNodeCount; i++)
                {
                    br.Read(buffer, 0, size);

                    n = new Node(Functions.ByteArrayToStructure<NodeStruct>(buffer));

                    nList = new List<Neighbor>();
                    for (int j = 0; j < 50; j++)
                    {
                        br.Read(neighbor, 0, nsize);

                        NeighborStruct neighborData = Functions.ByteArrayToStructure<NeighborStruct>(neighbor);
                        if (neighborData.id == -1) continue;
                        nList.Add(new Neighbor(neighborData));
                    }
                    n.Neighbors = nList;

                    _nodes.Add(n);
                }

                ConnectNodes();
        }