public Tilemap(int w, int h, Tilemap ft)
        {
            cmap = new CityMap(w, h);
            map = new Tile[w, h];
            fog = new Fog(w, h);
            name = ft.name;

            startpos = new Point(ft.startpos.X, ft.startpos.Y);

            for (int i = 0; i < w; i++)
                for (int e = 0; e < h; e++)
                {
                    if (i < ft.NumX && e < ft.NumY)
                    {
                        map[i, e] = ft.get(i, e);
                        fog.set(i, e, ft.Fog.get(i, e));
                        cmap.set(i, e, ft.CityMap.get(i, e));
                    }
                    else if (i < w && e < h)
                    {
                        map[i, e] = new Tile();
                        fog.set(i, e, false);
                    }
                }
        }
        public void load(String path)
        {
            name = Path.GetFileNameWithoutExtension(path);

            if (!VersionSys.match(path, vi))
                throw new Exception("File is not a Forgotten Schism Map file v1.0");

            FileStream fin = new FileStream(path, FileMode.Open);

            fin.Seek(12, SeekOrigin.Begin);

            startpos.X = fin.ReadByte();
            startpos.Y = fin.ReadByte();

            //map width and height
            int w = fin.ReadByte();
            int h = fin.ReadByte();

            map=new Tile[w,h];
            fog = new Fog(w, h);

            if(cmap==null)
                cmap = new CityMap(w, h);

            cmap.load(Path.ChangeExtension(path, ".citymap"));

            //map data

            int tt;

            for (int e = 0; e < h ; e++)
                for (int i = 0; i < w; i++)
                {
                    tt = fin.ReadByte();

                    fog.set(i, e, Gen.conv((byte)fin.ReadByte()));

                    map[i, e] = new Tile((Tile.TileType)tt);
                }

            fin.Close();
        }
        public static Fog fog(XmlElement e)
        {
            int numx = int.Parse(e.GetAttribute("numx"));
            int numy = int.Parse(e.GetAttribute("numy"));

            Fog f = new Fog(numx, numy);

            bool[] ba = Gen.BitPacker.unpack(Gen.hexstr(e.GetAttribute("data")));

            for (int j = 0; j < numy; j++)
                for (int i = 0; i < numx; i++)
                    f.set(i, j, ba[j * numx + i]);

            return f;
        }