INI parser used by MapMyne.
예제 #1
0
        static Map LoadMeta([NotNull] Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            MyneMetaFile metaFile = new MyneMetaFile(stream);

            if (metaFile.IsEmpty)
            {
                throw new MapFormatException("MapMyne: Metadata file is empty or incorrectly formatted.");
            }
            if (!metaFile.Contains("size", "x", "y", "z"))
            {
                throw new MapFormatException("MapMyne: Metadata file is missing map dimensions.");
            }

            int width  = Int32.Parse(metaFile["size", "x"]);
            int length = Int32.Parse(metaFile["size", "z"]);
            int height = Int32.Parse(metaFile["size", "y"]);

            Map map = new Map(null, width, length, height, false);


            if (metaFile.Contains("spawn", "x", "y", "z", "h"))
            {
                map.Spawn = new Position((short)(Int16.Parse(metaFile["spawn", "x"]) * 32 + 16),
                                         (short)(Int16.Parse(metaFile["spawn", "z"]) * 32 + 16),
                                         (short)(Int16.Parse(metaFile["spawn", "y"]) * 32 + 16),
                                         (byte)(Int32.Parse(metaFile["spawn", "h"]) * 255 / 360),
                                         0);
            }
            return(map);
        }
예제 #2
0
파일: MapMyne.cs 프로젝트: fragmer/fCraft
        static Map LoadMeta( [NotNull] Stream stream ) {
            if( stream == null ) throw new ArgumentNullException( "stream" );
            MyneMetaFile metaFile = new MyneMetaFile( stream );
            if( metaFile.IsEmpty ) {
                throw new MapFormatException( "MapMyne: Metadata file is empty or incorrectly formatted." );
            }
            if( !metaFile.Contains( "size", "x", "y", "z" ) ) {
                throw new MapFormatException( "MapMyne: Metadata file is missing map dimensions." );
            }

            int width = Int32.Parse( metaFile["size", "x"] );
            int length = Int32.Parse( metaFile["size", "z"] );
            int height = Int32.Parse( metaFile["size", "y"] );

            Map map = new Map( null, width, length, height, false );


            if( metaFile.Contains( "spawn", "x", "y", "z", "h" ) ) {
                map.Spawn = new Position( (short)(Int16.Parse( metaFile["spawn", "x"] )*32 + 16),
                                          (short)(Int16.Parse( metaFile["spawn", "z"] )*32 + 16),
                                          (short)(Int16.Parse( metaFile["spawn", "y"] )*32 + 16),
                                          (byte)(Int32.Parse( metaFile["spawn", "h"] )*255/360),
                                          0 );
            }
            return map;
        }