コード例 #1
0
        // Returns actual map data when given a map entry (from GetMapList)
        public static MapData GetMapData(FileStream wadStream, WADInfo wadInfo, WADMapEntry mapEntry)
        {
            var mapData = new MapData(wadInfo, mapEntry.Name,
                                      GetResource(wadStream, mapEntry.Things),
                                      GetResource(wadStream, mapEntry.LineDefs),
                                      GetResource(wadStream, mapEntry.SideDefs),
                                      GetResource(wadStream, mapEntry.Sectors),
                                      GetResource(wadStream, mapEntry.SubSectors),
                                      GetResource(wadStream, mapEntry.Segs),
                                      GetResource(wadStream, mapEntry.Vertexes));

            return(mapData);
        }
コード例 #2
0
        // Gets a list of maps in the WAD
        // At this level, we only care about metadata - so we get the name of the map and pointers to resources containing the map data
        public static List <WADMapEntry> GetMapList(FileStream wadStream, WADInfo wadInfo)
        {
            var maps = new List <WADMapEntry>();

            // Map names are either in the format "ExMy" or "MAPxx"
            // They also have a zero resource length as they're just markers in the WAD directory
            foreach (var entry in wadInfo.Entries.Where(e => (e.Name.StartsWith("MAP") || (e.Name[0] == 'E' && e.Name[2] == 'M')) && e.ResourceLength == 0))
            {
                var map = new WADMapEntry()
                {
                    Name = entry.Name
                };

                // The resource entries directly after the map marker are the actual map data
                // Let's find the ones we're interested in and hold pointers to them so we can get to them easily later
                var startIndex = wadInfo.Entries.IndexOf(entry);
                var index      = startIndex + 1;
                while (index < startIndex + 10 || index >= wadInfo.Entries.Count - 1)
                {
                    switch (wadInfo.Entries[index].Name)
                    {
                    case "THINGS": map.Things = wadInfo.Entries[index]; break;

                    case "LINEDEFS": map.LineDefs = wadInfo.Entries[index]; break;

                    case "SIDEDEFS": map.SideDefs = wadInfo.Entries[index]; break;

                    case "VERTEXES": map.Vertexes = wadInfo.Entries[index]; break;

                    case "SECTORS": map.Sectors = wadInfo.Entries[index]; break;

                    case "SSECTORS": map.SubSectors = wadInfo.Entries[index]; break;

                    case "SEGS": map.Segs = wadInfo.Entries[index]; break;
                    }

                    index++;
                }

                maps.Add(map);
            }

            return(maps);
        }