public static void CharacterRenameRequest(RealmClient client, RealmPacketIn packet) { if (client.Account == null) { return; } CharacterRecord cr = null; EntityId guid = packet.ReadEntityId(); string newName = packet.ReadString(); if (!client.Account.Characters.ContainsKey(guid)) { s_log.Error(Resources.IllegalRenameAttempt, guid.ToString(), RealmClient.GetInfo(client)); return; } else { cr = client.Account.Characters[guid]; if (((CharEnumFlags)cr.CharacterFlags & CharEnumFlags.NeedsRename) != CharEnumFlags.NeedsRename) { // their character isn't flagged to be renamed, what do they think they're doing? ;) client.Disconnect(); return; } } if (newName.Length == 0) { SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_INVALID); return; } if (Character.Exists(newName)) { SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_USED); return; } if (newName.Length < 3) { SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MIN_3); return; } if (newName.Length > 12) { SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_MAX_12); return; } if (Character.DoesNameViolate(newName)) { SendCharacterRenameError(client, AccountCharacterErrorCodes.ACCNT_MANIP_CHAR_NAME_PROFANITY); return; } s_log.Debug(Resources.RenamingCharacter, cr.Name, newName); cr.Name = newName.ToCapitalizedString(); cr.UpdateAndFlush(); client.Account.ReloadCharacters(); SendCharacterRenameSuccess(client, guid, newName); }