Ejemplo n.º 1
0
 public void CB_LOGIN_BY_PASSPORT(LoginConnection conn, Packet packet)
 {
     Send.BC_MESSAGE(conn, "Passport login not supported.");
     conn.Close();
 }
Ejemplo n.º 2
0
 public void CB_REQ_SLOT_PRICE(LoginConnection conn, Packet packet)
 {
     Send.BC_REQ_SLOT_PRICE(conn);
 }
Ejemplo n.º 3
0
 public void CB_REQ_CHANNEL_TRAFFIC(LoginConnection conn, Packet packet)
 {
     Send.BC_NORMAL_ZoneTraffic(conn);
 }
Ejemplo n.º 4
0
        public void CB_COMMANDER_CREATE(LoginConnection conn, Packet packet)
        {
            var charPosition = packet.GetByte();
            var name         = packet.GetString(65);
            var job          = (Job)packet.GetShort();
            var gender       = (Gender)packet.GetByte();
            var bx           = packet.GetFloat();
            var by           = packet.GetFloat();
            var bz           = packet.GetFloat();
            var hair         = packet.GetShort();


            if (conn.Account.GetCharacterByName(name) != null)
            {
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            var startingCity = StartingCity.Klaipeda;

            // Check starting city
            if (!Enum.IsDefined(typeof(StartingCity), startingCity))
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character in invalid starting city '{1}'.", conn.Account.Name, startingCity);
                Send.BC_MESSAGE(conn, MsgType.CreateCharFail);
                return;
            }

            // Check job
            if (job != Job.Swordsman && job != Job.Wizard && job != Job.Archer && job != Job.Cleric)
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character with invalid job '{1}'.", conn.Account.Name, job);
                conn.Close();
                return;
            }

            // Check gender
            if (gender < Gender.Male || gender > Gender.Female)
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character with invalid gender '{1}'.", conn.Account.Name, gender);
                conn.Close();
                return;
            }

            // Check name
            if (LoginServer.Instance.Database.CharacterExists(conn.Account.Id, name))
            {
                Send.BC_MESSAGE(conn, MsgType.NameAlreadyExists);
                return;
            }

            // Get job data
            var jobData = LoginServer.Instance.ClientData.JobDB.FirstOrDefault(x => x.JobId == (int)job);

            if (jobData == null)
            {
                Log.Error("CB_COMMANDER_CREATE: Job '{0}' not found.", job);
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            // Get start city data
            var startingCityData = LoginServer.Instance.ClientData.StartingCityDB.FirstOrDefault(x => x.StartingCityId == startingCity);

            if (startingCityData == null)
            {
                Log.Error("CB_COMMANDER_CREATE: StartingCity Id '{0}' not found.", startingCity);
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            // Get map data
            var mapData = LoginServer.Instance.ClientData.MapDB.FirstOrDefault(x => x.ClassName == startingCityData.Map);

            if (mapData == null)
            {
                Log.Error("CB_COMMANDER_CREATE: Map '{0}' not found.", startingCityData.Map);
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            var pos       = new Position(startingCityData.X, startingCityData.Y, startingCityData.Z);
            var character = conn.Account.CreateCharacter(name, gender, hair, jobData, mapData, pos);

            // persist the new character so that the ID may be sent to the client.
            LoginServer.Instance.Database.SaveAccount(conn.Account);

            Send.BC_COMMANDER_CREATE_SLOTID(conn, character);
            Send.BC_COMMANDER_CREATE(conn, character);
        }
Ejemplo n.º 5
0
        public void CB_COMMANDER_CREATE(LoginConnection conn, Packet packet)
        {
            var charPosition = packet.GetByte();
            var name         = packet.GetString(65);
            var job          = (JobId)packet.GetShort();
            var gender       = (Gender)packet.GetByte();
            var bx           = packet.GetFloat();
            var by           = packet.GetFloat();
            var bz           = packet.GetFloat();
            var hair         = packet.GetByte();
            var b1           = packet.GetByte();

            // Check job
            if (job != JobId.Swordsman && job != JobId.Wizard && job != JobId.Archer && job != JobId.Cleric)
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character with invalid job '{1}'.", conn.Account.Name, job);
                conn.Close();
                return;
            }

            // Check gender
            if (gender < Gender.Male || gender > Gender.Female)
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character with invalid gender '{1}'.", conn.Account.Name, gender);
                conn.Close();
                return;
            }

            // Check name
            if (LoginServer.Instance.Database.CharacterExists(conn.Account.Id, name))
            {
                Send.BC_MESSAGE(conn, MsgType.NameAlreadyExists);
                return;
            }

            // Get job data
            var jobData = LoginServer.Instance.Data.JobDb.Find(job);

            if (jobData == null)
            {
                Log.Error("CB_COMMANDER_CREATE: Job '{0}' not found.", job);
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            // Create
            var character = new Character();

            character.Name   = name;
            character.JobId  = job;
            character.Gender = gender;
            character.Hair   = hair;

            var startLocation = LoginServer.Instance.Conf.Login.StartLocation;

            character.MapId           = startLocation.MapId;
            character.Position        = new Position(startLocation.X, startLocation.Y, startLocation.Z);
            character.BarrackPosition = new Position(bx, by, bz);

            // XXX: Maybe we could get rid of this and the (sub-)stats in
            //   Character by passing the jobData to the database, for it
            //   get them itself? The creation is the only reason the stats
            //   exist in that class.
            character.Hp      = character.MaxHp = jobData.GetInitialHp();
            character.Sp      = character.MaxSp = jobData.GetInitialSp();
            character.Stamina = character.MaxStamina = jobData.Stamina;
            character.Str     = jobData.Str;
            character.Con     = jobData.Con;
            character.Int     = jobData.Int;
            character.Spr     = jobData.Spr;
            character.Dex     = jobData.Dex;

            // Initialize with the default equipment set.
            var equipment = new Dictionary <EquipSlot, int>();

            foreach (var equip in jobData.DefaultEquip)
            {
                var itemData = LoginServer.Instance.Data.ItemDb.FindByClass(equip.Value);
                if (itemData == null)
                {
                    Log.Error("CB_COMMANDER_CREATE : Unable to find item data with class name '{0}'.", equip.Value);
                    Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                    return;
                }

                equipment[equip.Key] = itemData.Id;
            }

            character.SetEquipment(equipment);

            conn.Account.CreateCharacter(character);

            Send.BC_COMMANDER_CREATE_SLOTID(conn, character);
            Send.BC_COMMANDER_CREATE(conn, character);
        }
Ejemplo n.º 6
0
        public void CB_COMMANDER_CREATE(LoginConnection conn, Packet packet)
        {
            var charPosition = packet.GetByte();
            var name         = packet.GetString(65);
            var job          = (Job)packet.GetShort();
            var gender       = (Gender)packet.GetByte();
            var bx           = packet.GetFloat();
            var by           = packet.GetFloat();
            var bz           = packet.GetFloat();
            var hair         = packet.GetByte();
            var startingCity = (StartingCity)packet.GetInt();

            // Check starting city
            if (!Enum.IsDefined(typeof(StartingCity), startingCity))
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character in invalid starting city '{1}'.", conn.Account.Name, startingCity);
                Send.BC_MESSAGE(conn, MsgType.CreateCharFail);
                return;
            }

            // Check job
            if (job != Job.Swordsman && job != Job.Wizard && job != Job.Archer && job != Job.Cleric)
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character with invalid job '{1}'.", conn.Account.Name, job);
                conn.Close();
                return;
            }

            // Check gender
            if (gender < Gender.Male || gender > Gender.Female)
            {
                Log.Warning("CB_COMMANDER_CREATE: User '{0}' tried to create character with invalid gender '{1}'.", conn.Account.Name, gender);
                conn.Close();
                return;
            }

            // Check name
            if (LoginServer.Instance.Database.CharacterExists(conn.Account.Id, name))
            {
                Send.BC_MESSAGE(conn, MsgType.NameAlreadyExists);
                return;
            }

            // Get job data
            var jobData = LoginServer.Instance.Data.JobDb.Find(job);

            if (jobData == null)
            {
                Log.Error("CB_COMMANDER_CREATE: Job '{0}' not found.", job);
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            // Get map data
            var mapData = LoginServer.Instance.Data.MapDb.Find(jobData.StartMap);

            if (mapData == null)
            {
                Log.Error("CB_COMMANDER_CREATE: Map '{0}' not found.", jobData.StartMap);
                Send.BC_MESSAGE(conn, MsgType.CannotCreateCharacter);
                return;
            }

            // Create
            var character = new Character();

            character.Name   = name;
            character.Job    = job;
            character.Gender = gender;
            character.Hair   = hair;

            character.MapId           = mapData.Id;
            character.Position        = new Position(jobData.StartX, jobData.StartY, jobData.StartZ);
            character.BarrackPosition = new Position(bx, by, bz);

            character.Hp      = character.MaxHp = 100;
            character.Sp      = character.MaxSp = 50;
            character.Stamina = character.MaxStamina = 25000;
            character.Str     = jobData.Str;
            character.Con     = jobData.Con;
            character.Int     = jobData.Int;
            character.Spr     = jobData.Spr;
            character.Dex     = jobData.Dex;

            conn.Account.CreateCharacter(character);

            Send.BC_COMMANDER_CREATE(conn, character);
        }