static bool DeleteCharAccessories(uint charId) { try { SpellRecord.DeleteAll("OwnerId = " + charId); AuraRecord.DeleteAll("OwnerId = " + charId); ItemRecord.DeleteAll("OwnerId = " + charId); SkillRecord.DeleteAll("OwnerId = " + charId); SpecProfile.DeleteAll("CharacterId = " + charId); ReputationRecord.DeleteAll("OwnerId = " + charId); QuestRecord.DeleteAll("OwnerId = " + charId); SummonedPetRecord.DeleteAll("OwnerLowId = " + charId); PermanentPetRecord.DeleteAll("OwnerLowId = " + charId); MailMgr.ReturnValueMailFor(charId); MailMessage.DeleteAll("ReceiverId = " + charId); RelationMgr.Instance.RemoveRelations(charId); InstanceMgr.RemoveLog(charId); GroupMgr.Instance.RemoveOfflineCharacter(charId); AchievementRecord.DeleteAll("CharacterId = " + charId); AchievementProgressRecord.DeleteAll("CharacterId = " + charId); return(true); } catch (Exception ex) { LogUtil.ErrorException(ex, "Failed to delete character with Id: " + charId); return(false); } }
private static void WritePlayerTalentList(BinaryWriter packet, Character chr, int talentGroupId) { SpecProfile currentSpecProfile = chr.CurrentSpecProfile; byte specProfileCount = (byte)chr.Talents.SpecProfileCount; packet.Write(chr.FreeTalentPoints); packet.Write(specProfileCount); packet.Write((byte)talentGroupId); if (specProfileCount <= (byte)0) { return; } Dictionary <TalentId, Talent> byId = chr.Talents.ById; uint[] glyphIds = currentSpecProfile.GlyphIds; for (int index1 = 0; index1 < (int)specProfileCount; ++index1) { packet.Write((byte)byId.Count); foreach (KeyValuePair <TalentId, Talent> keyValuePair in byId) { packet.Write((int)keyValuePair.Key); packet.Write((byte)keyValuePair.Value.Rank); } if (glyphIds != null) { packet.Write((byte)6); for (int index2 = 0; index2 < 6; ++index2) { packet.Write((short)glyphIds[index2]); } } else { packet.Write((byte)0); } } }
/// <summary> /// Loads this Character from DB when logging in. /// </summary> /// <remarks>Requires IO-Context.</remarks> internal protected void Load() { var nativeModel = m_archetype.Race.GetModel(m_record.Gender); NativeDisplayId = nativeModel.DisplayId; var model = nativeModel; if (m_record.DisplayId != model.DisplayId) { model = UnitMgr.GetModelInfo(m_record.DisplayId) ?? nativeModel; } Model = model; // set FreeTalentPoints silently UpdateFreeTalentPointsSilently(0); if (m_record.JustCreated) { // newly created Character SpecProfiles = new[] { SpecProfile.NewSpecProfile(this, 0) }; if (m_zone != null) { SetZoneExplored(m_zone.Template, true); } //m_record.FreeTalentPoints = 0; // Honor and Arena m_record.KillsTotal = 0u; m_record.HonorToday = 0u; m_record.HonorYesterday = 0u; m_record.LifetimeHonorableKills = 0u; m_record.HonorPoints = 0u; m_record.ArenaPoints = 0u; } else { // existing Character try { //Set Playerfields for glyphs on load InitGlyphsForLevel(); // load & validate SpecProfiles SpecProfiles = SpecProfile.LoadAllOfCharacter(this); if (SpecProfiles.Length == 0) { log.Warn("Character had no SpecProfiles: {0}", this); SpecProfiles = new[] { SpecProfile.NewSpecProfile(this, 0) }; } if (m_record.CurrentSpecIndex >= SpecProfiles.Length) { log.Warn("Character had invalid CurrentSpecIndex: {0} ({1})", this, m_record.CurrentSpecIndex); m_record.CurrentSpecIndex = 0; } // load all the rest m_achievements.Load(); ((PlayerSpellCollection)m_spells).LoadSpellsAndTalents(); ((PlayerSpellCollection)m_spells).LoadCooldowns(); m_skills.Load(); m_mailAccount.Load(); m_reputations.Load(); var auras = AuraRecord.LoadAuraRecords(EntityId.Low); AddPostUpdateMessage(() => m_auras.InitializeAuras(auras)); if (QuestMgr.Loaded) { LoadQuests(); } if (m_record.FinishedQuests != null) { m_questLog.FinishedQuests.AddRange(m_record.FinishedQuests); } } catch (Exception e) { RealmDBMgr.OnDBError(e); throw new Exception(string.Format("Failed to load Character \"{0}\" for Client: {1}", this, Client), e); } SetExploredZones(); //Add existing talents to the character ((PlayerSpellCollection)m_spells).PlayerInitialize(); // calculate amount of spent talent points per tree m_talents.CalcSpentTalentPoints(); // update RestState if (m_record.RestTriggerId != 0 && (m_restTrigger = AreaTriggerMgr.GetTrigger((uint)m_record.RestTriggerId)) != null) { RestState = RestState.Resting; } if (m_record.LastLogout != null) { var now = DateTime.Now; RestXp += RestGenerator.GetRestXp(now - m_record.LastLogout.Value, this); m_lastRestUpdate = now; } else { m_lastRestUpdate = DateTime.Now; } m_taxiNodeMask.Mask = m_record.TaxiMask; // Honor and Arena KillsTotal = m_record.KillsTotal; HonorToday = m_record.HonorToday; HonorYesterday = m_record.HonorYesterday; LifetimeHonorableKills = m_record.LifetimeHonorableKills; HonorPoints = m_record.HonorPoints; ArenaPoints = m_record.ArenaPoints; } // Set FreeTalentPoints, after SpecProfile was loaded var freePointsForLevel = m_talents.GetFreeTalentPointsForLevel(m_record.Level); m_talents.UpdateFreeTalentPointsSilently(freePointsForLevel); // Load pets (if any) LoadPets(); //foreach (var skill in m_skills) //{ // if (skill.SkillLine.Category == SkillCategory.ArmorProficiency) { // CharacterHandler.SendProfiency(m_client, ItemClass.Armor, (uint)skill.SkillLine.Id); // } //} // this prevents a the Char from re-sending a value update when being pushed to world AFTER creation ResetUpdateInfo(); }