Advertisement
Guest User

Untitled

a guest
Jun 4th, 2015
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1.   byte[,,] TibiaMap;
  2.         private void button8_Click(object sender, EventArgs e)
  3.         {
  4.             string Path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Tibia\\Automap\\";
  5.             int StartX = 31744;
  6.             int StartY = 30976;
  7.             int MaxHeight = 2048;
  8.             int MaxWidth = 2048;
  9.             TibiaMap = new byte[16, 2048, 2048];
  10.             DirectoryInfo di = new DirectoryInfo(Path);
  11.             for (int z = 0; z < 16; z++)
  12.             {
  13.                 FileInfo[] mapFiles = di.GetFiles("1??1??" +
  14.                    z.ToString("00") +
  15.                    ".map");
  16.                 foreach (FileInfo  inf in mapFiles)
  17.                 {
  18.                  
  19.                     Location RealLocation = MapFileNameToLocation(inf.Name);
  20.                     int ArrayX = RealLocation.X - StartX;
  21.                     int ArrayY = RealLocation.Y - StartY;
  22.  
  23.                    
  24.                     byte[] ColorArray = new byte[65536];
  25.                     FileStream fs = new FileStream(inf.FullName, FileMode.Open);
  26.                     BufferedStream bs = new BufferedStream(fs);
  27.                     bs.Read(ColorArray, 0, 65536);
  28.                     int index = 0;
  29.                     for (int x = 0; x < 256; x++)
  30.                     {
  31.                         for (int y = 0; y < 256; y++)
  32.                         {
  33.                             TibiaMap[z, x + ArrayX,y + ArrayY] = ColorArray[index];
  34.                             index += 1;
  35.                         }
  36.                     }
  37.                    
  38.                     fs.Close();
  39.                 }
  40.             }
  41.                          
  42.         }
  43.         private Location MapFileNameToLocation(string fileName)
  44.         {
  45.             Location l = new Location(0, 0, 0);
  46.             if (fileName.Length == 12 || fileName.Length == 8)
  47.             {
  48.                 l.X = Int32.Parse(fileName.Substring(0, 3)) * 256;
  49.                 l.Y = Int32.Parse(fileName.Substring(3, 3)) * 256;
  50.                 l.Z = Int32.Parse(fileName.Substring(6, 2));
  51.             }
  52.             return l;
  53.         }
  54.        
  55.         private void button9_Click(object sender, EventArgs e)
  56.         {
  57.          
  58.             int StartX = 31744;
  59.             int StartY = 30976;
  60.  
  61.             int arrayX = client.PlayerLocation.X  - StartX;
  62.             int arrayY = client.PlayerLocation.Y  - StartY;
  63.             MessageBox.Show(TibiaMap[client.PlayerLocation.Z, arrayX, arrayY].ToString());
  64.  
  65.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement