示例#1
0
        public void send_map_confirmation(String mapName, String serverKey)
        {
            currentMapName = mapName;

            try
            {
                mappie = new MapParser(mapName);
                mappie.Parse();
                String fullMapDirectory = Directory.GetCurrentDirectory() + "\\maps\\" + mapName + ".map";
                LogConsole("Map directory: " + fullMapDirectory);
                BinaryReader binReader = new BinaryReader(
                    new FileStream(fullMapDirectory, FileMode.Open));

                botLogics.AddPathFinder();


                byte[] bMap = binReader.ReadBytes(Convert.ToInt32(binReader.BaseStream.Length));
                int    sum  = 0;
                for (int i = 0; i < bMap.Length; i++)
                {
                    sum += (byte)bMap[i];
                }

                binReader.Close();

                PacketStream ps = new PacketStream();
                ps.WriteShort(packetNumber); ps.WriteByte(0xfc); ps.WriteByte(0x03);
                ps.WriteString(bMap.Length.ToString() + "|" + sum.ToString());
                byte[] hash = MapHasher.MapHash(serverKey);

                ps.WriteByte(10);
                for (int i = 0; i < 10; i++)
                {
                    ps.WriteByte(hash[i]);
                }
                ps.WriteByte(6);
                ch.SendStream(ps, true);
            }
            catch (Exception ex)
            {
                LogConsole(ex.Message);
            }
        }