All pastes #758386 Raw Edit

Mine

public text v1 · immutable
·published 2007-11-02 05:04 UTC
rendered paste body
//
// Decompiled with: Decompiler.NET, Version=2.0.0.11340, Culture=neutral, PublicKeyToken=null, Version: 2.0.0.11340
// Decompilation Started at: 05.05.2006 15:09:18
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. http://www.junglecreatures.com/
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace AOE.Login_Server
{

    #region Namespace Import Declarations

    using System;
    using System.Collections;
    using System.Data;
    using System.IO;
    using System.Text;

    #endregion

    public class Packet : Base
    {

        #region Fields
        private string m_acName;
        private byte[] m_breedBytes;
        private int m_breedInt;
        private byte[] m_name;
        private byte[] m_profBytes;
        private int m_profInt;
        private byte[] m_zoneBytes;
        private int m_zoneInt;
        #endregion

        #region Constructors

        public Packet()
        {
            this.m_acName = "";
        }

        #endregion

        #region Methods

        private string GetString(byte[] data,int startingOffset)
        {
            StringBuilder sb = new StringBuilder();
            byte b;
            while ((b = data[startingOffset]) != 0)
            {
                sb.Append((char)b);
            }

            return sb.ToString();
        }

        private string getName(byte[] packet)
        {
            string string1;
            byte[] byteArray1;
            int i1;
            int i2;
            byte[] byteArray2;
            byte[] byteArray3;
            byte[] byteArray4;
            Exception exception1;
            string string2;
            byte[] byteArray5;
            try
            {
                byteArray5 = new byte[1];
                byteArray1 = byteArray5;
                i1 = 24;
                i2 = 0;
                byteArray2 = new byte[1];
                byteArray3 = new byte[24];
                byteArray2[0] = packet[i1];
                while (!byteArray2[0].Equals(byteArray1[0]))
                {
                    byteArray3[i2] = byteArray2[0];
                    i1++;
                    i2++;
                    byteArray2[0] = packet[i1];
                }
                byteArray4 = new byte[i2];
                for (i1 = 0; (i1 < i2); i1++)
                {
                    byteArray4[i1] = byteArray3[i1];
                }
                string1 = Encoding.ASCII.GetString(byteArray4);
                string2 = string1;
            }
            catch (Exception exception2)
            {
                exception1 = exception2;
                Console.WriteLine(exception1.ToString());
                string2 = ((string)null);
            }
            return string2;
        }

        public byte[] Type(byte[] data, int x)
        {
            byte[] byteArray1 = data;

            int i1 = x;

            if ((x >= 128) && (x < 137))
            {
                x = 136;
            }

            DataTable characterDataTable;
            using (FileStream characterFile = new FileStream("System\\Player\\Character.xml", FileMode.Open, FileAccess.Read))
            {
                DataSet characterDataSet = new DataSet();
                characterDataSet.ReadXml(characterFile);
                characterDataTable = characterDataSet.Tables[0];
            }
             
            foreach (DataRow dataRow in characterDataTable.Rows)
            {
                m_name = Encoding.ASCII.GetBytes(dataRow["Name"].ToString());
                m_profInt = int.Parse(dataRow["Prof"].ToString());
                m_profBytes = BitConverter.GetBytes(m_profInt);
                m_breedInt = int.Parse(dataRow["Breed"].ToString());
                m_breedBytes = BitConverter.GetBytes(m_breedInt);
            }

            DataTable coordsDataTable;
            using (FileStream coordsFile = new FileStream("System\\Player\\Coords.xml", FileMode.Open, FileAccess.Read))
            {
                DataSet coordsDataSet = new DataSet();
                coordsDataSet.ReadXml(coordsFile);
                coordsDataTable = coordsDataSet.Tables[0];
            }

            foreach (DataRow dataRow in coordsDataTable.Rows)
            {
                m_zoneInt = int.Parse(dataRow["ZoneID"].ToString());
                m_zoneBytes = BitConverter.GetBytes(m_zoneInt);
            }

            // why is this never assigned?
            byte[] byteArray2 = null;

            // response when dataLength = 84
            byte[] byteArray3 = new byte[]
                {
                    0xDF, 0xDF, 0, 1, 0, 1, 0, 52, 0, 0, // 10
                    0, 1, 0, 0, 43, 63, 0, 0, 0, 36, // 20
                    55, 57, 57, 54, 56, 51, 98, 101, 98, 52, // 30
                    48, 48, 54, 98, 97, 56, 52, 97, 54, 54, // 40
                    54, 55, 53, 102, 53, 101, 99, 50, 57, 99, // 50
                    57, 55 // 52
                };

            // response when dataLength = 452
            byte[] byteArray6 = new byte[]
                {
                    0xDF, 0xDF, 0, 1, 0, 1, 0, 141, 0, 0, // 10
                    0, 1, 0, 0, 97, 91, 0, 0, 0, 14, // 20
                    0, 0, 0, 1, 0, 0, 0, 4, 73, 150, // 30
                    2, 210, 97, 0, 0, 199, 157, 0, 0, 0, // 40
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50
                    0, 156, 80, 0, 43, 119, 108, 0, 0, 0, // 60
                    1, 0, 0, 0, 4, 73, 150, 2, 210, 0, // 70
                    0, 0, 8, 0, 0, 0, 0, 0, 0, 0, // 80
                    0, 0, 0, 0, 0, 0, 0, 0, 3, 0, // 90
                    0, 0, 0, 0, 0, 1, 144, 0, 0, 0, // 100
                    12, 97, 114, 101, 97, 32, 117, 110, 107, 110, // 110
                    111, 119, 110, 0, 0, 0, 0, 0, 0, 0, // 120
                    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 130
                    0, 0, 0, 0, 0, 0, 8, 0, 0, 0, // 140
                    3, 100, 55, 56 // 144
                };

            byteArray6[38] = m_zoneBytes[2];
            byteArray6[39] = m_zoneBytes[1];
            byteArray6[40] = m_zoneBytes[0];
            byteArray6[73] = m_name[0];
            byteArray6[74] = m_name[1];
            byteArray6[75] = m_name[2];
            byteArray6[76] = m_name[3];
            byteArray6[77] = m_name[4];
            byteArray6[78] = m_name[5];
            byteArray6[79] = m_name[6];
            byteArray6[80] = m_name[7];
            byteArray6[84] = m_breedBytes[0];
            byteArray6[92] = m_profBytes[0];

            // response when dataLength = 28
            byte[] byteArray5 = new byte[]
                {
                    0xDF, 0xDF, 0, 1, 0, 1, 0, 38, 0, 0, // 10
                    0, 1, 0, 0, 97, 91, 0, 0, 0, 23, // 20
                    73, 150, 2, 210, 127, 0, 0, 1, 29, 77, // 30
                    111, 90, 13, 82, 85, 45, 117, 22, 56, 46 // 40
                };

            int i2 = x;

            if (i2 <= 84)
            {
                if (i2 == 28)
                {
                    // dataLength == 28
                    return byteArray5;
                }
                else if (i2 != 84)
                {
                    // return null as byteArray2 is never assigned
                    return byteArray2;
                }
                else
                {
                    // dataLength == 84
                    //m_acName = getName(data);
                    m_acName = GetString(data, 24);
                    return byteArray3;
                }
            }
            if (i2 != 136)
            {
                if ((i2 != 194) && (i2 == 452))
                {
                    // dataLength = 452
                    return byteArray6;
                }
                else
                {
                    // return null as byteArray2 is never assigned
                    return byteArray2;
                }
            }
            Create create1 = new Create();
            create1.CreateToon(byteArray1, i1);
            return byteArray5;
        }

        #endregion
    }

}