예제 #1
0
 /// <summary>
 /// Get land tile and static tiles from specified map.
 /// </summary>
 /// <param name="facet">Target map.</param>
 /// <param name="x">X coordinate.</param>
 /// <param name="y">Y coordinate.</param>
 /// <param name="mapInfo">MapInfo (out).</param>
 /// <returns>True on success.</returns>
 public static bool GetMapInfo(Facet facet, int x, int y, out MapInfo mapInfo)
 {
     switch (facet)
     {
         case Facet.Felucca:
             return Map.GetInfo(0, x, y, out mapInfo);
         case Facet.Trammel:
             return Map.GetInfo(1, x, y, out mapInfo);
         case Facet.Ilshenar:
             return Map.GetInfo(2, x, y, out mapInfo);
         case Facet.Malas:
             return Map.GetInfo(3, x, y, out mapInfo);
         case Facet.Tokuno:
             return Map.GetInfo(4, x, y, out mapInfo);
         case Facet.Ter_Mur:
             return Map.GetInfo(5, x, y, out mapInfo);
     }
     mapInfo = null;
     return false;
 }
예제 #2
0
        internal static bool GetInfo(int map, int x, int y, out MapInfo mapInfo)
        {
            MapInfo m = new MapInfo();
            if (x < 0 || y < 0)
            {
                mapInfo = null;
                return false;
            }

            int blockIndex;
            int cellX = x % 8;
            int cellY = y % 8;

            switch (map)
            {
                case 0:
                    if (myMap0Reader == null || (myUsingNewMaps && (x > myNewMap0XLimit || y > myNewMap0YLimit)) ||
                        (!myUsingNewMaps && (x > myOldMap0XLimit || y > myOldMap0YLimit)))
                    {
                        mapInfo = null;
                        return false;
                    }
                    blockIndex = x / 8 * 512 + y / 8;
                    lock (myMap0Lock)
                    {
                        int offset = blockIndex * 196 + 4 + (cellY * 24 + cellX * 3);

                        if (myMap0Index != null)
                            offset = myMap0Index.Lookup(offset);

                        myMap0Reader.Seek(offset, SeekOrigin.Begin);
                        m.landTile = new LandTile(TileData.GetLandTile(myMap0Reader.ReadByte() | myMap0Reader.ReadByte() << 8));
                        m.landTile.X = x;
                        m.landTile.Y = y;
                        m.landTile.Z = (sbyte)myMap0Reader.ReadByte();
                    }
                    m.staticTiles = GetStaticTiles(0, x, y);
                    mapInfo = m;
                    return true;
                case 1:
                    if (myMap1Reader == null || (myUsingNewMaps && (x > myNewMap1XLimit || y > myNewMap1YLimit)) ||
                        (!myUsingNewMaps && (x > myOldMap1XLimit || y > myOldMap1YLimit)))
                    {
                        mapInfo = null;
                        return false;
                    }

                    blockIndex = x / 8 * 512 + y / 8;
                    mapInfo = new MapInfo();
                    lock (myMap1Lock)
                    {
                        int offset = blockIndex * 196 + 4 + (cellY * 24 + cellX * 3);

                        if (myMap1Index != null)
                            offset = myMap1Index.Lookup(offset);

                        myMap1Reader.Seek(offset, SeekOrigin.Begin);
                        mapInfo.landTile = new LandTile(TileData.GetLandTile(myMap1Reader.ReadByte() | myMap1Reader.ReadByte() << 8));
                        mapInfo.landTile.X = x;
                        mapInfo.landTile.Y = y;
                        mapInfo.landTile.Z = (sbyte)myMap1Reader.ReadByte();
                    }
                    mapInfo.staticTiles = GetStaticTiles(1, x, y);
                    return true;
                case 2:
                    if (myMap2Reader == null || x > myMap2XLimit || y > myMap2YLimit)
                    {
                        mapInfo = null;
                        return false;
                    }
                    blockIndex = x / 8 * 200 + y / 8;
                    lock (myMap2Lock)
                    {
                        int offset = blockIndex * 196 + 4 + (cellY * 24 + cellX * 3);

                        if (myMap2Index != null)
                            offset = myMap2Index.Lookup(offset);

                        myMap2Reader.Seek(offset, SeekOrigin.Begin);
                        m.landTile = new LandTile(TileData.GetLandTile(myMap2Reader.ReadByte() | myMap2Reader.ReadByte() << 8));
                        m.landTile.X = x;
                        m.landTile.Y = y;
                        m.landTile.Z = (sbyte)myMap2Reader.ReadByte();
                    }
                    m.staticTiles = GetStaticTiles(2, x, y);
                    mapInfo = m;
                    return true;
                case 3:
                    if (myMap3Reader == null || x > myMap3XLimit || y > myMap3YLimit)
                    {
                        mapInfo = null;
                        return false;
                    }
                    blockIndex = x / 8 * 256 + y / 8;
                    lock (myMap3Lock)
                    {
                        int offset = blockIndex * 196 + 4 + (cellY * 24 + cellX * 3);

                        if (myMap3Index != null)
                            offset = myMap3Index.Lookup(offset);

                        myMap3Reader.Seek(offset, SeekOrigin.Begin);
                        m.landTile = new LandTile(TileData.GetLandTile(myMap3Reader.ReadByte() | myMap3Reader.ReadByte() << 8));
                        m.landTile.X = x;
                        m.landTile.Y = y;
                        m.landTile.Z = (sbyte)myMap3Reader.ReadByte();
                    }
                    m.staticTiles = GetStaticTiles(3, x, y);
                    mapInfo = m;
                    return true;
                case 4:
                    if (myMap4Reader == null || x > myMap4XLimit || y > myMap4YLimit)
                    {
                        mapInfo = null;
                        return false;
                    }
                    blockIndex = x / 8 * 181 + y / 8;
                    lock (myMap4Lock)
                    {
                        int offset = blockIndex * 196 + 4 + (cellY * 24 + cellX * 3);

                        if (myMap4Index != null)
                            offset = myMap4Index.Lookup(offset);

                        myMap4Reader.Seek(offset, SeekOrigin.Begin);

                        m.landTile = new LandTile(TileData.GetLandTile(myMap4Reader.ReadByte() | myMap4Reader.ReadByte() << 8));
                        m.landTile.X = x;
                        m.landTile.Y = y;
                        m.landTile.Z = (sbyte)myMap4Reader.ReadByte();
                    }
                    m.staticTiles = GetStaticTiles(4, x, y);
                    mapInfo = m;
                    return true;
                case 5:
                    if (myMap5Reader == null || x > myMap5XLimit || y > myMap5YLimit)
                    {
                        mapInfo = null;
                        return false;
                    }
                    blockIndex = x / 8 * 512 + y / 8;
                    lock (myMap5Lock)
                    {
                        int offset = blockIndex * 196 + 4 + (cellY * 24 + cellX * 3);

                        if (myMap5Index != null)
                            offset = myMap5Index.Lookup(offset);

                        myMap5Reader.Seek(offset, SeekOrigin.Begin);

                        m.landTile = new LandTile(TileData.GetLandTile(myMap5Reader.ReadByte() | myMap5Reader.ReadByte() << 8));
                        m.landTile.X = x;
                        m.landTile.Y = y;
                        m.landTile.Z = (sbyte)myMap5Reader.ReadByte();
                    }
                    m.staticTiles = GetStaticTiles(5, x, y);
                    mapInfo = m;
                    return true;
            }
            mapInfo = null;
            return false;
        }