/// <summary> /// /// </summary> private static void SQL_HandleCharLogin( CharLoginSQL sqlInfo ) { ////////////////////////////////////////////////////////////////////////// // 读取人物基础信息(CharacterBase) // 读取人物状态信息(CharacterBase) // 读取道具信息(CharacterItem) // 读取技能信息(CharacterSkill) // 读取法术信息(CharacterSpell) // 读取天赋信息(CharactersGift) // 读取宠物信息(CharacterPet) // 读取探索信息(CharacterExplore) // 读取声望信息(CharacterReputation) // 读取邮件信息(Mail) // 读取飞行点信息(CharactersTaxi) // 读取快捷按钮信息(CharacterActionBar) // 读取好友信息(CharacterSocial) // 读取行会信息(Guild)/ // 读取团队信息(Group) // 读取组队信息 ? // 计算攻防信息 // 读取人物增益/减益信息(CharacterAura) // 读取法书/道具冷却信息(CharacterSpellCooldown) ////////////////////////////////////////////////////////////////////////// // 读取人物基础信息(CharacterBase) XPQuery<CharacterBase> characters = new XPQuery<CharacterBase>( OneDatabase.Session ); var characterList = from character in characters where character.Oid == sqlInfo.LoginCharGuid select character; bool bIsFinde = false; WowCharacter wowCharacter = new WowCharacter(); foreach ( CharacterBase character in characterList ) { ////////////////////////////////////////////////////////////////////////// // 读取人物状态信息(CharacterBase) wowCharacter.GuildGuid = character.Oid; wowCharacter.Name = character.CharacterName; wowCharacter.Level = (uint)character.Level; wowCharacter.Race = (uint)character.Race; wowCharacter.Class = (uint)character.Class; wowCharacter.ZoneId = (uint)character.ZoneId; wowCharacter.MapId = (uint)character.MapId; wowCharacter.X = character.PositionX; wowCharacter.Y = character.PositionY; wowCharacter.Z = character.PositionZ; wowCharacter.Gender = (uint)character.Gender; wowCharacter.Face = (uint)character.Face; wowCharacter.HairStyle = (uint)character.HairStyle; wowCharacter.HairColor = (uint)character.HairColor; wowCharacter.FacialHair = (uint)character.FacialHair; ////////////////////////////////////////////////////////////////////////// // 读取道具信息(CharacterItem) XPQuery<CharacterItem> characterItems = new XPQuery<CharacterItem>( OneDatabase.Session ); var characterItemList = from characterItem in characterItems where characterItem.Owner == character && characterItem.BagId > InventorySlotBag.InventorySlotEquipmentBag && characterItem.BagId < InventorySlotBag.InventorySlotMainBag select characterItem; foreach ( CharacterItem characterItem in characterItemList ) { if ( characterItem.SlotId != BaseItem.SlotNotSet ) continue; WowItemContainer wowItemContainer = wowCharacter.BagManager.FindContainerAtSlot( characterItem.BagId ) as WowItemContainer; if ( wowItemContainer != null ) continue; else { WowItemTemplate wowItemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate( (Serial)characterItem.ItemTemplateGuid ) as WowItemTemplate; if ( wowItemTemplate == null ) continue; wowItemContainer = new WowItemContainer(); wowItemContainer.InitContainerSlot( 0, wowItemTemplate.ContainerSlots ); wowItemContainer.Item = new WowItem(); wowItemContainer.Item.Serial = characterItem.Oid; wowItemContainer.Item.ItemTemplate = wowItemTemplate; wowCharacter.BagManager.AddContainer( characterItem.BagId, wowItemContainer ); } } characterItemList = from characterItem in characterItems select characterItem; foreach ( CharacterItem characterItem in characterItemList ) { if ( characterItem.SlotId != BaseItem.SlotNotSet ) continue; WowItem wowItem = new WowItem(); wowItem.Serial = characterItem.Oid; if ( characterItem.BagId == InventorySlotBag.InventorySlotEquipmentBag ) { if ( characterItem.SlotId == BaseItem.SlotNotSet || characterItem.SlotId < EquipmentSlot.EquipmentSlotStart || characterItem.SlotId >= EquipmentSlot.EquipmentSlotEnd ) continue; if ( wowCharacter.BagManager.EquipmentBag.FindSubItemAtSlot( characterItem.SlotId ) != null ) continue; wowCharacter.BagManager.EquipmentBag.AddSubItem( characterItem.SlotId, wowItem ); } else if ( characterItem.BagId == InventorySlotBag.InventorySlotMainBag ) { if ( characterItem.SlotId == BaseItem.SlotNotSet || characterItem.SlotId < BagSlotItem.BagSlotItemStart || characterItem.SlotId >= BagSlotItem.BagSlotItemEnd ) continue; if ( wowCharacter.BagManager.EquipmentBag.FindSubItemAtSlot( characterItem.SlotId ) != null ) continue; wowCharacter.BagManager.MainBag.AddSubItem( characterItem.SlotId, wowItem ); } else { WowItemContainer wowItemContainer = wowCharacter.BagManager.FindContainerAtSlot( characterItem.BagId ) as WowItemContainer; if ( wowItemContainer == null ) continue; else { if ( wowItemContainer.FindSubItemAtSlot( characterItem.SlotId ) != null ) continue; wowItemContainer.AddSubItem( characterItem.SlotId, wowItem ); } } } ////////////////////////////////////////////////////////////////////////// // 读取技能信息(CharacterSkill) XPQuery<CharacterSkill> characterSkills = new XPQuery<CharacterSkill>( OneDatabase.Session ); var characterSkillList = from characterSkill in characterSkills where characterSkill.Owner == character select characterSkill; foreach ( CharacterSkill characterSkill in characterSkillList ) { WowSkill wowSkill = new WowSkill(); wowSkill.Serial = characterSkill.SkillId; wowCharacter.SkillManager.AddSkill( wowSkill.Serial, wowSkill ); } ////////////////////////////////////////////////////////////////////////// // 读取法术信息(CharacterSpell) XPQuery<CharacterSpell> characterSpells = new XPQuery<CharacterSpell>( OneDatabase.Session ); var characterSpellList = from characterSpell in characterSpells where characterSpell.Owner == character select characterSpell; foreach ( CharacterSpell characterSpell in characterSpellList ) { WowSpell wowSpell = new WowSpell(); wowSpell.Serial = characterSpell.SpellId; wowCharacter.SpellManager.AddSpell( wowSpell.Serial, wowSpell ); } ////////////////////////////////////////////////////////////////////////// // 读取天赋信息(CharactersGift) XPQuery<CharactersGift> charactersGifts = new XPQuery<CharactersGift>( OneDatabase.Session ); var charactersGiftList = from charactersGift in charactersGifts where charactersGift.Owner == character select charactersGift; foreach ( CharactersGift charactersGift in charactersGiftList ) { WowTalent wowTalent = new WowTalent(); wowTalent.Serial = charactersGift.Oid; wowCharacter.TalentManager.AddTalent( wowTalent.Serial, wowTalent ); } ////////////////////////////////////////////////////////////////////////// // 读取宠物信息(CharacterPet) XPQuery<CharacterPet> characterPets = new XPQuery<CharacterPet>( OneDatabase.Session ); var characterPetList = from characterPet in characterPets where characterPet.Owner == character select characterPet; foreach ( CharacterPet characterPet in characterPetList ) { WowPet wowPet = new WowPet(); } ////////////////////////////////////////////////////////////////////////// // 读取探索信息(CharacterExplore) XPQuery<CharacterExplore> characterExplores = new XPQuery<CharacterExplore>( OneDatabase.Session ); var characterExploreList = from characterExplore in characterExplores where characterExplore.Owner == character select characterExplore; foreach ( CharacterExplore characterExplore in characterExploreList ) { } ////////////////////////////////////////////////////////////////////////// // 读取声望信息(CharacterReputation) XPQuery<CharacterReputation> characterReputations = new XPQuery<CharacterReputation>( OneDatabase.Session ); var characterReputationList = from characterReputation in characterReputations where characterReputation.Owner == character select characterReputation; foreach ( CharacterReputation characterReputation in characterReputationList ) { } ////////////////////////////////////////////////////////////////////////// // 读取邮件信息(Mail) XPQuery<Mail> mails = new XPQuery<Mail>( OneDatabase.Session ); var mailList = from mail in mails where mail.Receiver == character select mail; foreach ( Mail mail in mailList ) { } ////////////////////////////////////////////////////////////////////////// // 读取飞行点信息(CharactersTaxi) XPQuery<CharactersTaxi> charactersTaxis = new XPQuery<CharactersTaxi>( OneDatabase.Session ); var charactersTaxiList = from charactersTaxi in charactersTaxis where charactersTaxi.Owner == character select charactersTaxi; foreach ( CharactersTaxi charactersTaxi in charactersTaxiList ) { } ////////////////////////////////////////////////////////////////////////// // 读取快捷按钮信息(CharacterActionBar) XPQuery<CharacterActionBar> characterActionBars = new XPQuery<CharacterActionBar>( OneDatabase.Session ); var characterActionBarList = from characterActionBar in characterActionBars where characterActionBar.Owner == character select characterActionBar; foreach ( CharacterActionBar characterActionBar in characterActionBarList ) { } ////////////////////////////////////////////////////////////////////////// // 读取好友信息(CharacterSocial) XPQuery<CharacterSocial> characterSocials = new XPQuery<CharacterSocial>( OneDatabase.Session ); var characterSocialList = from characterSocial in characterSocials where characterSocial.Owner == character select characterSocial; foreach ( CharacterSocial characterSocial in characterSocialList ) { } ////////////////////////////////////////////////////////////////////////// // 读取行会信息(Guild) XPQuery<Guild> guilds = new XPQuery<Guild>( OneDatabase.Session ); var guildList = from guild in guilds where guild.Leader == character select guild; foreach ( Guild guild in guildList ) { } ////////////////////////////////////////////////////////////////////////// // 读取团队信息(Group) XPQuery<Group> groups = new XPQuery<Group>( OneDatabase.Session ); var groupList = from groupItem in groups where groupItem.Leader == character select groupItem; foreach ( Group group in groupList ) { } ////////////////////////////////////////////////////////////////////////// // 读取组队信息 ? ////////////////////////////////////////////////////////////////////////// // 计算攻防信息 ////////////////////////////////////////////////////////////////////////// // 读取人物增益/减益信息(CharacterAura) XPQuery<CharacterAura> characterAuras = new XPQuery<CharacterAura>( OneDatabase.Session ); var characterAuraList = from characterAura in characterAuras where characterAura.Owner == character select characterAura; foreach ( CharacterAura characterAura in characterAuraList ) { } ////////////////////////////////////////////////////////////////////////// // 读取法书/道具冷却信息(CharacterSpellCooldown) XPQuery<CharacterSpellCooldown> characterSpellCooldowns = new XPQuery<CharacterSpellCooldown>( OneDatabase.Session ); var characterSpellCooldownList = from characterSpellCooldown in characterSpellCooldowns where characterSpellCooldown.Owner == character select characterSpellCooldown; foreach ( CharacterSpellCooldown characterSpellCooldown in characterSpellCooldownList ) { } bIsFinde = true; break; } if ( bIsFinde == false ) { Debug.WriteLine( "CHAR_LOGIN_FAILED error!" ); sqlInfo.NetState.Send( new Word_PlayerLoginFailedResponse( ResponseCodes.CHAR_LOGIN_FAILED ) ); return; } sqlInfo.NetState.Send( new Word_PlayerDungeonDifficulty( InstanceMode.MODE_NORMAL ) ); sqlInfo.NetState.Send( new Word_PlayerLoginVerifyWorld( wowCharacter.MapId, wowCharacter.X, wowCharacter.Y, wowCharacter.Z, wowCharacter.O ) ); AccountData[] accountDataArray = new AccountData[8]; for ( int iIndex = 0; iIndex < accountDataArray.Length; iIndex++ ) accountDataArray[iIndex] = new AccountData(); sqlInfo.NetState.Send( new Word_PlayerAccountDataMd5( accountDataArray ) ); sqlInfo.NetState.Send( new Word_PlayerVoiceSystemStatus( 0 ) );// 需要连接套接字 sqlInfo.NetState.Send( new Word_PlayerTriggerCinematic( 0 ) ); sqlInfo.NetState.Send( new Word_PlayerBroadcastMsg( "ookk1234567" ) ); sqlInfo.NetState.Send( new Word_PlayerSetRestStart() ); sqlInfo.NetState.Send( new Word_PlayerBindPointUpdate( wowCharacter.X, wowCharacter.Y, wowCharacter.Z, wowCharacter.MapId, wowCharacter.ZoneId ) ); uint[] uiTutorialArray = new uint[8]; for ( int iIndex = 0; iIndex < uiTutorialArray.Length; iIndex++ ) uiTutorialArray[iIndex] = 0; sqlInfo.NetState.Send( new Word_PlayerTutorialFlags( uiTutorialArray ) ); sqlInfo.NetState.Send( new Word_PlayerInitialSpells( wowCharacter.SpellManager.ToArray(), wowCharacter.SpellCooldownManager.ToArray() ) ); sqlInfo.NetState.Send( new Word_PlayerActionButtons( wowCharacter.ActionBarManager.ToArray() ) ); sqlInfo.NetState.Send( new Word_PlayerInitializeFactions( wowCharacter.ReputationManager.ToArray() ) ); sqlInfo.NetState.Send( new Word_PlayerInitWorldStates( wowCharacter.MapId, wowCharacter.ZoneId, 0 ) ); sqlInfo.NetState.Send( new Word_PlayerLoginSetTimeSpeed( DateTime.Now ) ); }
/// <summary> /// /// </summary> public Word_PlayerInitialSpells( WowSpell[] wowSpellArray, WowSpellCooldown[] wowSpellCoolDownArray ) : base( (long)WordOpCode.SMSG_INITIAL_SPELLS, 0 ) { WriterStream.Write( (ushort)0 /* 2 + ? */ ); // Size WriterStream.Write( (ushort)WordOpCode.SMSG_INITIAL_SPELLS ); // ID ////////////////////////////////////////////////////////////////////////// WriterStream.Write( (byte)0 ); WriterStream.Write( (ushort)wowSpellArray.Length ); for ( int iIndex = 0; iIndex < wowSpellArray.Length; iIndex++ ) { WriterStream.Write( (ushort)wowSpellArray[iIndex].Level ); WriterStream.Write( (ushort)0 ); } // SpellCooldown WriterStream.Write( (ushort)wowSpellCoolDownArray.Length ); for ( int iIndex = 0; iIndex < wowSpellCoolDownArray.Length; iIndex++ ) { WriterStream.Write( (ushort)wowSpellCoolDownArray[iIndex].Level ); WriterStream.Write( (ushort)0 ); WriterStream.Write( (ushort)0 ); if ( wowSpellCoolDownArray[iIndex].Level != 0 ) { WriterStream.Write( (uint)0 ); WriterStream.Write( (uint)0 ); } else { WriterStream.Write( (uint)0 ); WriterStream.Write( (uint)0 ); } } ////////////////////////////////////////////////////////////////////////// WriterStream.Seek( 0, SeekOrigin.Begin ); WriterStream.Write( (ushort)ByteOrder.NetToHost( (ushort)( WriterStream.Length - 2/*Size本身的大小*/ ) ) ); }
/// <summary> /// /// </summary> private static void SQL_HandleCharLogin(CharLoginSQL sqlInfo) { ////////////////////////////////////////////////////////////////////////// // 读取人物基础信息(CharacterBase) // 读取人物状态信息(CharacterBase) // 读取道具信息(CharacterItem) // 读取技能信息(CharacterSkill) // 读取法术信息(CharacterSpell) // 读取天赋信息(CharactersGift) // 读取宠物信息(CharacterPet) // 读取探索信息(CharacterExplore) // 读取声望信息(CharacterReputation) // 读取邮件信息(Mail) // 读取飞行点信息(CharactersTaxi) // 读取快捷按钮信息(CharacterActionBar) // 读取好友信息(CharacterSocial) // 读取行会信息(Guild)/ // 读取团队信息(Group) // 读取组队信息 ? // 计算攻防信息 // 读取人物增益/减益信息(CharacterAura) // 读取法书/道具冷却信息(CharacterSpellCooldown) ////////////////////////////////////////////////////////////////////////// // 读取人物基础信息(CharacterBase) XPQuery <CharacterBase> characters = new XPQuery <CharacterBase>(OneDatabase.Session); var characterList = from character in characters where character.Oid == sqlInfo.LoginCharGuid select character; bool bIsFinde = false; WowCharacter wowCharacter = new WowCharacter(); foreach (CharacterBase character in characterList) { ////////////////////////////////////////////////////////////////////////// // 读取人物状态信息(CharacterBase) wowCharacter.GuildGuid = character.Oid; wowCharacter.Name = character.CharacterName; wowCharacter.Level = (uint)character.Level; wowCharacter.Race = (uint)character.Race; wowCharacter.Class = (uint)character.Class; wowCharacter.ZoneId = (uint)character.ZoneId; wowCharacter.MapId = (uint)character.MapId; wowCharacter.X = character.PositionX; wowCharacter.Y = character.PositionY; wowCharacter.Z = character.PositionZ; wowCharacter.Gender = (uint)character.Gender; wowCharacter.Face = (uint)character.Face; wowCharacter.HairStyle = (uint)character.HairStyle; wowCharacter.HairColor = (uint)character.HairColor; wowCharacter.FacialHair = (uint)character.FacialHair; ////////////////////////////////////////////////////////////////////////// // 读取道具信息(CharacterItem) XPQuery <CharacterItem> characterItems = new XPQuery <CharacterItem>(OneDatabase.Session); var characterItemList = from characterItem in characterItems where characterItem.Owner == character && characterItem.BagId > InventorySlotBag.InventorySlotEquipmentBag && characterItem.BagId < InventorySlotBag.InventorySlotMainBag select characterItem; foreach (CharacterItem characterItem in characterItemList) { if (characterItem.SlotId != BaseItem.SlotNotSet) { continue; } WowItemContainer wowItemContainer = wowCharacter.BagManager.FindContainerAtSlot(characterItem.BagId) as WowItemContainer; if (wowItemContainer != null) { continue; } else { WowItemTemplate wowItemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate((Serial)characterItem.ItemTemplateGuid) as WowItemTemplate; if (wowItemTemplate == null) { continue; } wowItemContainer = new WowItemContainer(); wowItemContainer.InitContainerSlot(0, wowItemTemplate.ContainerSlots); wowItemContainer.Item = new WowItem(); wowItemContainer.Item.Serial = characterItem.Oid; wowItemContainer.Item.ItemTemplate = wowItemTemplate; wowCharacter.BagManager.AddContainer(characterItem.BagId, wowItemContainer); } } characterItemList = from characterItem in characterItems select characterItem; foreach (CharacterItem characterItem in characterItemList) { if (characterItem.SlotId != BaseItem.SlotNotSet) { continue; } WowItem wowItem = new WowItem(); wowItem.Serial = characterItem.Oid; if (characterItem.BagId == InventorySlotBag.InventorySlotEquipmentBag) { if (characterItem.SlotId == BaseItem.SlotNotSet || characterItem.SlotId < EquipmentSlot.EquipmentSlotStart || characterItem.SlotId >= EquipmentSlot.EquipmentSlotEnd) { continue; } if (wowCharacter.BagManager.EquipmentBag.FindSubItemAtSlot(characterItem.SlotId) != null) { continue; } wowCharacter.BagManager.EquipmentBag.AddSubItem(characterItem.SlotId, wowItem); } else if (characterItem.BagId == InventorySlotBag.InventorySlotMainBag) { if (characterItem.SlotId == BaseItem.SlotNotSet || characterItem.SlotId < BagSlotItem.BagSlotItemStart || characterItem.SlotId >= BagSlotItem.BagSlotItemEnd) { continue; } if (wowCharacter.BagManager.EquipmentBag.FindSubItemAtSlot(characterItem.SlotId) != null) { continue; } wowCharacter.BagManager.MainBag.AddSubItem(characterItem.SlotId, wowItem); } else { WowItemContainer wowItemContainer = wowCharacter.BagManager.FindContainerAtSlot(characterItem.BagId) as WowItemContainer; if (wowItemContainer == null) { continue; } else { if (wowItemContainer.FindSubItemAtSlot(characterItem.SlotId) != null) { continue; } wowItemContainer.AddSubItem(characterItem.SlotId, wowItem); } } } ////////////////////////////////////////////////////////////////////////// // 读取技能信息(CharacterSkill) XPQuery <CharacterSkill> characterSkills = new XPQuery <CharacterSkill>(OneDatabase.Session); var characterSkillList = from characterSkill in characterSkills where characterSkill.Owner == character select characterSkill; foreach (CharacterSkill characterSkill in characterSkillList) { WowSkill wowSkill = new WowSkill(); wowSkill.Serial = characterSkill.SkillId; wowCharacter.SkillManager.AddSkill(wowSkill.Serial, wowSkill); } ////////////////////////////////////////////////////////////////////////// // 读取法术信息(CharacterSpell) XPQuery <CharacterSpell> characterSpells = new XPQuery <CharacterSpell>(OneDatabase.Session); var characterSpellList = from characterSpell in characterSpells where characterSpell.Owner == character select characterSpell; foreach (CharacterSpell characterSpell in characterSpellList) { WowSpell wowSpell = new WowSpell(); wowSpell.Serial = characterSpell.SpellId; wowCharacter.SpellManager.AddSpell(wowSpell.Serial, wowSpell); } ////////////////////////////////////////////////////////////////////////// // 读取天赋信息(CharactersGift) XPQuery <CharactersGift> charactersGifts = new XPQuery <CharactersGift>(OneDatabase.Session); var charactersGiftList = from charactersGift in charactersGifts where charactersGift.Owner == character select charactersGift; foreach (CharactersGift charactersGift in charactersGiftList) { WowTalent wowTalent = new WowTalent(); wowTalent.Serial = charactersGift.Oid; wowCharacter.TalentManager.AddTalent(wowTalent.Serial, wowTalent); } ////////////////////////////////////////////////////////////////////////// // 读取宠物信息(CharacterPet) XPQuery <CharacterPet> characterPets = new XPQuery <CharacterPet>(OneDatabase.Session); var characterPetList = from characterPet in characterPets where characterPet.Owner == character select characterPet; foreach (CharacterPet characterPet in characterPetList) { WowPet wowPet = new WowPet(); } ////////////////////////////////////////////////////////////////////////// // 读取探索信息(CharacterExplore) XPQuery <CharacterExplore> characterExplores = new XPQuery <CharacterExplore>(OneDatabase.Session); var characterExploreList = from characterExplore in characterExplores where characterExplore.Owner == character select characterExplore; foreach (CharacterExplore characterExplore in characterExploreList) { } ////////////////////////////////////////////////////////////////////////// // 读取声望信息(CharacterReputation) XPQuery <CharacterReputation> characterReputations = new XPQuery <CharacterReputation>(OneDatabase.Session); var characterReputationList = from characterReputation in characterReputations where characterReputation.Owner == character select characterReputation; foreach (CharacterReputation characterReputation in characterReputationList) { } ////////////////////////////////////////////////////////////////////////// // 读取邮件信息(Mail) XPQuery <Mail> mails = new XPQuery <Mail>(OneDatabase.Session); var mailList = from mail in mails where mail.Receiver == character select mail; foreach (Mail mail in mailList) { } ////////////////////////////////////////////////////////////////////////// // 读取飞行点信息(CharactersTaxi) XPQuery <CharactersTaxi> charactersTaxis = new XPQuery <CharactersTaxi>(OneDatabase.Session); var charactersTaxiList = from charactersTaxi in charactersTaxis where charactersTaxi.Owner == character select charactersTaxi; foreach (CharactersTaxi charactersTaxi in charactersTaxiList) { } ////////////////////////////////////////////////////////////////////////// // 读取快捷按钮信息(CharacterActionBar) XPQuery <CharacterActionBar> characterActionBars = new XPQuery <CharacterActionBar>(OneDatabase.Session); var characterActionBarList = from characterActionBar in characterActionBars where characterActionBar.Owner == character select characterActionBar; foreach (CharacterActionBar characterActionBar in characterActionBarList) { } ////////////////////////////////////////////////////////////////////////// // 读取好友信息(CharacterSocial) XPQuery <CharacterSocial> characterSocials = new XPQuery <CharacterSocial>(OneDatabase.Session); var characterSocialList = from characterSocial in characterSocials where characterSocial.Owner == character select characterSocial; foreach (CharacterSocial characterSocial in characterSocialList) { } ////////////////////////////////////////////////////////////////////////// // 读取行会信息(Guild) XPQuery <Guild> guilds = new XPQuery <Guild>(OneDatabase.Session); var guildList = from guild in guilds where guild.Leader == character select guild; foreach (Guild guild in guildList) { } ////////////////////////////////////////////////////////////////////////// // 读取团队信息(Group) XPQuery <Group> groups = new XPQuery <Group>(OneDatabase.Session); var groupList = from groupItem in groups where groupItem.Leader == character select groupItem; foreach (Group group in groupList) { } ////////////////////////////////////////////////////////////////////////// // 读取组队信息 ? ////////////////////////////////////////////////////////////////////////// // 计算攻防信息 ////////////////////////////////////////////////////////////////////////// // 读取人物增益/减益信息(CharacterAura) XPQuery <CharacterAura> characterAuras = new XPQuery <CharacterAura>(OneDatabase.Session); var characterAuraList = from characterAura in characterAuras where characterAura.Owner == character select characterAura; foreach (CharacterAura characterAura in characterAuraList) { } ////////////////////////////////////////////////////////////////////////// // 读取法书/道具冷却信息(CharacterSpellCooldown) XPQuery <CharacterSpellCooldown> characterSpellCooldowns = new XPQuery <CharacterSpellCooldown>(OneDatabase.Session); var characterSpellCooldownList = from characterSpellCooldown in characterSpellCooldowns where characterSpellCooldown.Owner == character select characterSpellCooldown; foreach (CharacterSpellCooldown characterSpellCooldown in characterSpellCooldownList) { } bIsFinde = true; break; } if (bIsFinde == false) { Debug.WriteLine("CHAR_LOGIN_FAILED error!"); sqlInfo.NetState.Send(new Word_PlayerLoginFailedResponse(ResponseCodes.CHAR_LOGIN_FAILED)); return; } sqlInfo.NetState.Send(new Word_PlayerDungeonDifficulty(InstanceMode.MODE_NORMAL)); sqlInfo.NetState.Send(new Word_PlayerLoginVerifyWorld(wowCharacter.MapId, wowCharacter.X, wowCharacter.Y, wowCharacter.Z, wowCharacter.O)); AccountData[] accountDataArray = new AccountData[8]; for (int iIndex = 0; iIndex < accountDataArray.Length; iIndex++) { accountDataArray[iIndex] = new AccountData(); } sqlInfo.NetState.Send(new Word_PlayerAccountDataMd5(accountDataArray)); sqlInfo.NetState.Send(new Word_PlayerVoiceSystemStatus(0)); // 需要连接套接字 sqlInfo.NetState.Send(new Word_PlayerTriggerCinematic(0)); sqlInfo.NetState.Send(new Word_PlayerBroadcastMsg("ookk1234567")); sqlInfo.NetState.Send(new Word_PlayerSetRestStart()); sqlInfo.NetState.Send(new Word_PlayerBindPointUpdate(wowCharacter.X, wowCharacter.Y, wowCharacter.Z, wowCharacter.MapId, wowCharacter.ZoneId)); uint[] uiTutorialArray = new uint[8]; for (int iIndex = 0; iIndex < uiTutorialArray.Length; iIndex++) { uiTutorialArray[iIndex] = 0; } sqlInfo.NetState.Send(new Word_PlayerTutorialFlags(uiTutorialArray)); sqlInfo.NetState.Send(new Word_PlayerInitialSpells(wowCharacter.SpellManager.ToArray(), wowCharacter.SpellCooldownManager.ToArray())); sqlInfo.NetState.Send(new Word_PlayerActionButtons(wowCharacter.ActionBarManager.ToArray())); sqlInfo.NetState.Send(new Word_PlayerInitializeFactions(wowCharacter.ReputationManager.ToArray())); sqlInfo.NetState.Send(new Word_PlayerInitWorldStates(wowCharacter.MapId, wowCharacter.ZoneId, 0)); sqlInfo.NetState.Send(new Word_PlayerLoginSetTimeSpeed(DateTime.Now)); }
/// <summary> /// /// </summary> internal bool SaveNewCreature() { XPQuery <CharacterBase> characters = new XPQuery <CharacterBase>(OneDatabase.Session); var characterList = from character in characters where character.Oid == m_CharacterAccountGuid select character; if (characterList.Count() > WOW_MAX_CHARACTER_COUNT) // 人物过多 { return(false); } CharacterBase newCharacter = new CharacterBase(OneDatabase.Session); this.Serial = newCharacter.Oid; newCharacter.CharacterName = this.Name; //newCharacter.Account = this.AccountGuid; newCharacter.Gender = (byte)this.Gender; newCharacter.Skin = (byte)this.Skin; newCharacter.Face = (byte)this.Face; newCharacter.HairStyle = (byte)this.HairColor; newCharacter.HairColor = (byte)this.HairColor; newCharacter.FacialHair = (byte)this.FacialHair; newCharacter.Race = (byte)this.Race; newCharacter.Class = (int)this.Class; newCharacter.Level = (int)this.Level; newCharacter.MapId = (int)this.MapId; newCharacter.ZoneId = (int)this.ZoneId; newCharacter.PositionX = this.X; newCharacter.PositionY = this.Y; newCharacter.PositionZ = this.Z; newCharacter.Orientation = this.O; newCharacter.Guild = null; // 人物的坐骑航线标记点 32位值|32位值|32位值|32位值 // 00000000000000000000000000000000|...|...|... // 以位域标示 1~TaxiId~32| 32~TaxiId~64|65~TaxiId~96|96~TaxiId~128 newCharacter.TaxiMask = this.TaxiMask; newCharacter.IsGhost = false; newCharacter.IsCinematic = false; newCharacter.IsNeedRename = false; newCharacter.TotalTime = 0; newCharacter.LevelTime = 0; newCharacter.LogoutTime = DateTime.Now; newCharacter.CreatingTime = DateTime.Now; newCharacter.IsBanned = false; newCharacter.IsDelete = false; newCharacter.DeleteTime = DateTime.Now; CharacterHomeBind newCharacterHomeBind = new CharacterHomeBind(OneDatabase.Session); //newCharacterHomeBind.Owner = newCharacter.Oid; newCharacterHomeBind.MapId = (int)this.BindMapId; newCharacterHomeBind.ZoneId = (int)this.BindZoneId; newCharacterHomeBind.PositionX = this.BindX; newCharacterHomeBind.PositionY = this.BindY; newCharacterHomeBind.PositionZ = this.BindZ; foreach (BaseSkill baseSkill in SkillManager.ToArray()) { WowSkill wowSkill = baseSkill as WowSkill; if (wowSkill == null) { continue; } if (wowSkill.Serial != 0) { continue; } WowSkillTemplate wowSkillTemplate = wowSkill.SkillTemplate as WowSkillTemplate; if (wowSkillTemplate == null) { continue; } CharacterSkill newCharactersSkill = new CharacterSkill(OneDatabase.Session); wowSkill.Serial = newCharactersSkill.Oid; //newCharactersSkill.Owner = newCharacter.Oid; newCharactersSkill.SkillId = wowSkillTemplate.Serial; newCharactersSkill.Value = wowSkill.Level; } foreach (BaseSpell baseSpell in SpellManager.ToArray()) { WowSpell wowSpell = baseSpell as WowSpell; if (wowSpell == null) { continue; } if (wowSpell.Serial != 0) { continue; } WowSpellTemplate wowSpellTemplate = baseSpell.SpellTemplate as WowSpellTemplate; if (wowSpellTemplate == null) { continue; } CharacterSpell newCharacterSpell = new CharacterSpell(OneDatabase.Session); wowSpell.Serial = newCharacterSpell.Oid; //newCharacterSpell.Owner = newCharacter.Oid; newCharacterSpell.SpellId = wowSpellTemplate.Serial; //newCharacterSpell.Slot = baseSpell.Slot; } foreach (WowActionBar baseActionBar in ActionBarManager.ToArray()) { WowActionBar wowActionBar = baseActionBar as WowActionBar; if (baseActionBar == null) { continue; } if (wowActionBar.Serial != 0) { continue; } CharacterActionBar newCharactersAction = new CharacterActionBar(OneDatabase.Session); wowActionBar.Serial = newCharactersAction.Oid; //newCharactersAction.Owner= newCharacter.Oid; newCharactersAction.Slot = wowActionBar.ActionBarSlotId; newCharactersAction.ActionId = wowActionBar.Action; newCharactersAction.ActionType = wowActionBar.Type; } foreach (BaseItem baseItem in BagManager.EquipmentBag.SubItemsToArray()) { WowItem wowItem = baseItem as WowItem; if (wowItem == null) { continue; } if (wowItem.Serial != 0) { continue; } WowItemTemplate wowItemTemplate = wowItem.ItemTemplate as WowItemTemplate; if (wowItemTemplate == null) { continue; } CharacterItem newCharactersItem = new CharacterItem(OneDatabase.Session); wowItem.Serial = newCharactersItem.Oid; //newCharactersItem.Owner = newCharacter.Oid; newCharactersItem.ItemTemplateGuid = (ulong)wowItemTemplate.Serial; newCharactersItem.Amount = (int)wowItem.Amount; newCharactersItem.BagId = (int)BagManager.EquipmentBag.Item.SlotId; newCharactersItem.SlotId = (int)wowItem.SlotId; } foreach (WowReputation baseReputation in ReputationManager.ToArray()) { WowReputation wowReputation = baseReputation as WowReputation; if (wowReputation == null) { continue; } if (wowReputation.Serial != 0) { continue; } CharacterReputation newCharacterReputation = new CharacterReputation(OneDatabase.Session); wowReputation.Serial = newCharacterReputation.Oid; //newCharacterReputation.Owner = newCharacter.Oid; newCharacterReputation.FactionId = wowReputation.FactionId; newCharacterReputation.Reputation = wowReputation.Reputation; newCharacterReputation.Flag = wowReputation.Flag; } return(true); }
/// <summary> /// /// </summary> /// <param name="netState"></param> /// <param name="packetReader"></param> internal static void World_HandleCharCreate(NetState netState, PacketReader packetReader) { WorldExtendData extendData = netState.GetComponent <WorldExtendData>(WorldExtendData.COMPONENT_ID); if (extendData == null) { Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData == null error!"); return; } if (extendData.IsLoggedIn == false) { Debug.WriteLine("World_PacketHandlers.World_HandleCharEnum(...) - extendData.IsLoggedIn == false error!"); return; } string strName = packetReader.ReadUTF8StringSafe(); byte iRace = packetReader.ReadByte(); byte iClass = packetReader.ReadByte(); byte iGender = packetReader.ReadByte(); byte iSkin = packetReader.ReadByte(); byte iFace = packetReader.ReadByte(); byte iHairStyle = packetReader.ReadByte(); byte iHairColor = packetReader.ReadByte(); byte iFacialHair = packetReader.ReadByte(); byte iOutFitId = packetReader.ReadByte(); if (WorldPacketHandlers.VerifyName(strName) == false) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } if (ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.GetPlayerInfo(strName) != null) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } WowCharacterCreateInfo wowCharacterCreateInfo = ProcessServer.WowZoneCluster.World.GlobalCreateInfo.GetCreateInfo(iRace, iClass); if (wowCharacterCreateInfo == null) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } if ((iRace == WowRace.BloodElf || iRace == WowRace.Draenei) && extendData.CommonData.IsTBC == false) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } WowCharacterLevelInfo[] wowCharacterLevelInfo = ProcessServer.WowZoneCluster.World.GlobalLevelInfo.GetLevelInfo(iRace, iClass); if (wowCharacterLevelInfo == null) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } WowCharacter wowPlayerInfo = new WowCharacter(); wowPlayerInfo.Serial = 0; wowPlayerInfo.IsTBC = extendData.CommonData.IsTBC; wowPlayerInfo.AccountGuid = extendData.CommonData.AccountsGuid; wowPlayerInfo.Name = strName; wowPlayerInfo.Race = iRace; wowPlayerInfo.Class = iClass; wowPlayerInfo.Gender = iGender; wowPlayerInfo.Skin = iSkin; wowPlayerInfo.Face = iFace; wowPlayerInfo.HairStyle = iHairStyle; wowPlayerInfo.HairColor = iHairColor; wowPlayerInfo.FacialHair = iFacialHair; wowPlayerInfo.X = wowCharacterCreateInfo.PositionX; wowPlayerInfo.Y = wowCharacterCreateInfo.PositionY; wowPlayerInfo.Z = wowCharacterCreateInfo.PositionZ; wowPlayerInfo.MapId = wowCharacterCreateInfo.Map; wowPlayerInfo.ZoneId = wowCharacterCreateInfo.Zone; wowPlayerInfo.BindX = 0; wowPlayerInfo.BindY = 0; wowPlayerInfo.BindZ = 0; wowPlayerInfo.BindMapId = 0; wowPlayerInfo.BindZoneId = 0; ChrRacesEntry chrRacesEntry = DBCInstances.ChrRacesEntry.LookupIDEntry(iRace); if (chrRacesEntry == null) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } if (chrRacesEntry.m_TeamId == 7) { wowPlayerInfo.TeamId = WowTeam.ALLIANCE; } else { wowPlayerInfo.TeamId = WowTeam.HORDE; } ChrClassesEntry chrClassesEntry = DBCInstances.ChrClassesEntry.LookupIDEntry(iClass); if (chrClassesEntry == null) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } wowPlayerInfo.PowerType = chrClassesEntry.m_PowerType; switch (iRace) { case (byte)WowRace.Tauren: wowPlayerInfo.TaxiMask[0] = 1 << (22 - 1); break; case (byte)WowRace.Human: wowPlayerInfo.TaxiMask[0] = 1 << (2 - 1); break; case (byte)WowRace.Dwarf: wowPlayerInfo.TaxiMask[0] = 1 << (6 - 1); break; case (byte)WowRace.Gnome: wowPlayerInfo.TaxiMask[0] = 1 << (6 - 1); break; case (byte)WowRace.Orc: wowPlayerInfo.TaxiMask[0] = 1 << (23 - 1); break; case (byte)WowRace.Troll: wowPlayerInfo.TaxiMask[0] = 1 << (23 - 1); break; case (byte)WowRace.Undead: wowPlayerInfo.TaxiMask[0] = 1 << (11 - 1); break; case (byte)WowRace.Nightelf: wowPlayerInfo.TaxiMask[0] = 1 << (27 - 1); break; case (byte)WowRace.BloodElf: wowPlayerInfo.TaxiMask[2] = 1 << (18 - 1); break; case (byte)WowRace.Draenei: wowPlayerInfo.TaxiMask[2] = 1 << (30 - 1); break; } wowPlayerInfo.Size = (iRace == WowRace.Tauren) ? 1.3f : 1.0f; wowPlayerInfo.Health = wowCharacterLevelInfo[0].Health; wowPlayerInfo.Mana = wowCharacterLevelInfo[0].Mana; wowPlayerInfo.Rage = 0; wowPlayerInfo.Focus = 0; wowPlayerInfo.Energy = 0; wowPlayerInfo.MaxHealth = wowCharacterLevelInfo[0].Health; wowPlayerInfo.MaxMana = wowCharacterLevelInfo[0].Mana; wowPlayerInfo.MaxRage = 0; wowPlayerInfo.MaxFocus = 0; wowPlayerInfo.MaxEnergy = 0; wowPlayerInfo.BaseHealth = wowCharacterLevelInfo[0].Health; wowPlayerInfo.BaseMana = wowCharacterLevelInfo[0].Mana; wowPlayerInfo.FactionTemplate = 0; wowPlayerInfo.Level = 1; wowPlayerInfo.Strength = wowCharacterLevelInfo[0].Strength; wowPlayerInfo.Agility = wowCharacterLevelInfo[0].Agility; wowPlayerInfo.Stamina = wowCharacterLevelInfo[0].Stamina; wowPlayerInfo.Intellect = wowCharacterLevelInfo[0].Intellect; wowPlayerInfo.Spirit = wowCharacterLevelInfo[0].Spirit; wowPlayerInfo.BoundingRadius = 0.388999998569489f; wowPlayerInfo.CombatReach = 1.5f; if (iGender == 0) { wowPlayerInfo.DisplayId = wowCharacterCreateInfo.MaleDisplayId; wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.MaleDisplayId; } else { wowPlayerInfo.DisplayId = wowCharacterCreateInfo.FemaleDisplayId; wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.FemaleDisplayId; } wowPlayerInfo.AttackPower = 0; wowPlayerInfo.NextLevelXP = 400; wowPlayerInfo.MaxLevel = 10; for (uint iIndex = 0; iIndex < DBCInstances.FactionEntry.Count; iIndex++) { FactionEntry factionEntry = DBCInstances.FactionEntry.LookupRowEntry(iIndex); if (factionEntry == null) { continue; } if (factionEntry.m_RepListId < 0) { continue; } int iReputation = 0; if ((factionEntry.m_BaseRepMask1 & (1 << (iRace - 1))) != 0) { iReputation = (int)factionEntry.m_BaseRepValue1; } else if ((factionEntry.m_BaseRepMask2 & (1 << (iRace - 1))) != 0) { iReputation = (int)factionEntry.m_BaseRepValue2; } else if ((factionEntry.m_BaseRepMask3 & (1 << (iRace - 1))) != 0) { iReputation = (int)factionEntry.m_BaseRepValue3; } else if ((factionEntry.m_BaseRepMask4 & (1 << (iRace - 1))) != 0) { iReputation = (int)factionEntry.m_BaseRepValue4; } else { continue; } WowReputation wowReputation = new WowReputation() { FactionId = factionEntry.ID, Reputation = iReputation, }; if ((int)wowReputation.CalcRating() <= (int)WowFactionRating.Hostile) { wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagAtWar; } if ((factionEntry.m_Team == 469 && wowPlayerInfo.TeamId == WowTeam.ALLIANCE) || (factionEntry.m_Team == 67 && wowPlayerInfo.TeamId == WowTeam.HORDE)) { wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagVisible; } wowPlayerInfo.ReputationManager.AddReputation(wowReputation.FactionId, wowReputation); } foreach (WowPlayerInfoSkill wowPlayerInfoSkill in wowCharacterCreateInfo.WowPlayerSkills.Skills) { WowSkillTemplate wowSkillTemplate = ProcessServer.WowZoneCluster.World.GlobalSkillTemplates.GetSkillTemplate((long)wowPlayerInfoSkill.Skill) as WowSkillTemplate; if (wowSkillTemplate == null) { continue; } WowSkill wowSkill = new WowSkill() { Serial = wowSkillTemplate.SkillId, SkillTemplate = wowSkillTemplate }; wowPlayerInfo.SkillManager.AddSkill(wowSkill.Serial, wowSkill); } foreach (WowPlayerInfoSpell wowPlayerInfoSpell in wowCharacterCreateInfo.WowPlayerSpells.Spells) { WowSpellTemplate wowSpellTemplate = ProcessServer.WowZoneCluster.World.GlobalSpellTemplates.GetSpellTemplate((long)wowPlayerInfoSpell.Spell) as WowSpellTemplate; if (wowSpellTemplate == null) { continue; } WowSpell wowSpell = new WowSpell() { Serial = wowSpellTemplate.SpellId, SpellTemplate = wowSpellTemplate }; wowPlayerInfo.SpellManager.AddSpell(wowSpell.Serial, wowSpell); } foreach (WowPlayerInfoItem wowPlayerInfoItem in wowCharacterCreateInfo.WowPlayerItems.Items) { WowItemTemplate wowItemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate((long)wowPlayerInfoItem.ItemId) as WowItemTemplate; if (wowItemTemplate == null) { continue; } WowItemContainer equipmentBag = wowPlayerInfo.BagManager.EquipmentBag; if (equipmentBag == null) { break; } WowItem wowItem = equipmentBag.FindSubItemAtSlot(wowItemTemplate.InventoryType) as WowItem; if (wowItem == null) { wowItem = new WowItem() { ItemTemplate = wowItemTemplate }; equipmentBag.AddSubItem(wowItemTemplate.InventoryType, wowItem); } else { WowItemContainer mainBag = wowPlayerInfo.BagManager.MainBag; if (mainBag == null) { break; } wowItem = new WowItem() { ItemTemplate = wowItemTemplate }; mainBag.AddToFreeSlot(wowItem); } } foreach (WowPlayerInfoAction wowPlayerInfoAction in wowCharacterCreateInfo.WowPlayerActions.Actions) { WowActionBar wowActionBar = new WowActionBar() { Serial = wowPlayerInfoAction.Button, Action = wowPlayerInfoAction.Action, Type = wowPlayerInfoAction.Type }; wowPlayerInfo.ActionBarManager.AddActionBar(wowActionBar.Serial, wowActionBar); } if (wowPlayerInfo.SaveNewCreature() == false) { netState.Send(new Word_CharCreateResponseError(ResponseCodes.CHAR_CREATE_NAME_IN_USE)); return; } ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.AddPlayerInfo(wowPlayerInfo.Name, wowPlayerInfo.Serial, wowPlayerInfo); netState.Send(new Word_CharCreateResponse()); }
/// <summary> /// /// </summary> /// <param name="netState"></param> /// <param name="packetReader"></param> internal static void World_HandleCharCreate( NetState netState, PacketReader packetReader ) { WorldExtendData extendData = netState.GetComponent<WorldExtendData>( WorldExtendData.COMPONENT_ID ); if ( extendData == null ) { Debug.WriteLine( "World_PacketHandlers.World_HandleCharEnum(...) - extendData == null error!" ); return; } if ( extendData.IsLoggedIn == false ) { Debug.WriteLine( "World_PacketHandlers.World_HandleCharEnum(...) - extendData.IsLoggedIn == false error!" ); return; } string strName = packetReader.ReadUTF8StringSafe(); byte iRace = packetReader.ReadByte(); byte iClass = packetReader.ReadByte(); byte iGender = packetReader.ReadByte(); byte iSkin = packetReader.ReadByte(); byte iFace = packetReader.ReadByte(); byte iHairStyle = packetReader.ReadByte(); byte iHairColor = packetReader.ReadByte(); byte iFacialHair = packetReader.ReadByte(); byte iOutFitId = packetReader.ReadByte(); if ( WorldPacketHandlers.VerifyName( strName ) == false ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } if ( ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.GetPlayerInfo( strName ) != null ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } WowCharacterCreateInfo wowCharacterCreateInfo = ProcessServer.WowZoneCluster.World.GlobalCreateInfo.GetCreateInfo( iRace, iClass ); if ( wowCharacterCreateInfo == null ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } if ( ( iRace == WowRace.BloodElf || iRace == WowRace.Draenei ) && extendData.CommonData.IsTBC == false ) { netState.Send ( new Word_CharCreateResponseError ( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } WowCharacterLevelInfo[] wowCharacterLevelInfo = ProcessServer.WowZoneCluster.World.GlobalLevelInfo.GetLevelInfo( iRace, iClass ); if ( wowCharacterLevelInfo == null ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } WowCharacter wowPlayerInfo = new WowCharacter(); wowPlayerInfo.Serial = 0; wowPlayerInfo.IsTBC = extendData.CommonData.IsTBC; wowPlayerInfo.AccountGuid = extendData.CommonData.AccountsGuid; wowPlayerInfo.Name = strName; wowPlayerInfo.Race = iRace; wowPlayerInfo.Class = iClass; wowPlayerInfo.Gender = iGender; wowPlayerInfo.Skin = iSkin; wowPlayerInfo.Face = iFace; wowPlayerInfo.HairStyle = iHairStyle; wowPlayerInfo.HairColor = iHairColor; wowPlayerInfo.FacialHair = iFacialHair; wowPlayerInfo.X = wowCharacterCreateInfo.PositionX; wowPlayerInfo.Y = wowCharacterCreateInfo.PositionY; wowPlayerInfo.Z = wowCharacterCreateInfo.PositionZ; wowPlayerInfo.MapId = wowCharacterCreateInfo.Map; wowPlayerInfo.ZoneId = wowCharacterCreateInfo.Zone; wowPlayerInfo.BindX = 0; wowPlayerInfo.BindY = 0; wowPlayerInfo.BindZ = 0; wowPlayerInfo.BindMapId = 0; wowPlayerInfo.BindZoneId = 0; ChrRacesEntry chrRacesEntry = DBCInstances.ChrRacesEntry.LookupIDEntry( iRace ); if ( chrRacesEntry == null ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } if ( chrRacesEntry.m_TeamId == 7 ) wowPlayerInfo.TeamId = WowTeam.ALLIANCE; else wowPlayerInfo.TeamId = WowTeam.HORDE; ChrClassesEntry chrClassesEntry = DBCInstances.ChrClassesEntry.LookupIDEntry( iClass ); if ( chrClassesEntry == null ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } wowPlayerInfo.PowerType = chrClassesEntry.m_PowerType; switch ( iRace ) { case (byte)WowRace.Tauren: wowPlayerInfo.TaxiMask[0] = 1 << ( 22 - 1 ); break; case (byte)WowRace.Human: wowPlayerInfo.TaxiMask[0] = 1 << ( 2 - 1 ); break; case (byte)WowRace.Dwarf: wowPlayerInfo.TaxiMask[0] = 1 << ( 6 - 1 ); break; case (byte)WowRace.Gnome: wowPlayerInfo.TaxiMask[0] = 1 << ( 6 - 1 ); break; case (byte)WowRace.Orc: wowPlayerInfo.TaxiMask[0] = 1 << ( 23 - 1 ); break; case (byte)WowRace.Troll: wowPlayerInfo.TaxiMask[0] = 1 << ( 23 - 1 ); break; case (byte)WowRace.Undead: wowPlayerInfo.TaxiMask[0] = 1 << ( 11 - 1 ); break; case (byte)WowRace.Nightelf: wowPlayerInfo.TaxiMask[0] = 1 << ( 27 - 1 ); break; case (byte)WowRace.BloodElf: wowPlayerInfo.TaxiMask[2] = 1 << ( 18 - 1 ); break; case (byte)WowRace.Draenei: wowPlayerInfo.TaxiMask[2] = 1 << ( 30 - 1 ); break; } wowPlayerInfo.Size = ( iRace == WowRace.Tauren ) ? 1.3f : 1.0f; wowPlayerInfo.Health = wowCharacterLevelInfo[0].Health; wowPlayerInfo.Mana = wowCharacterLevelInfo[0].Mana; wowPlayerInfo.Rage = 0; wowPlayerInfo.Focus = 0; wowPlayerInfo.Energy = 0; wowPlayerInfo.MaxHealth = wowCharacterLevelInfo[0].Health; wowPlayerInfo.MaxMana = wowCharacterLevelInfo[0].Mana; wowPlayerInfo.MaxRage = 0; wowPlayerInfo.MaxFocus = 0; wowPlayerInfo.MaxEnergy = 0; wowPlayerInfo.BaseHealth = wowCharacterLevelInfo[0].Health; wowPlayerInfo.BaseMana = wowCharacterLevelInfo[0].Mana; wowPlayerInfo.FactionTemplate = 0; wowPlayerInfo.Level = 1; wowPlayerInfo.Strength = wowCharacterLevelInfo[0].Strength; wowPlayerInfo.Agility = wowCharacterLevelInfo[0].Agility; wowPlayerInfo.Stamina = wowCharacterLevelInfo[0].Stamina; wowPlayerInfo.Intellect = wowCharacterLevelInfo[0].Intellect; wowPlayerInfo.Spirit = wowCharacterLevelInfo[0].Spirit; wowPlayerInfo.BoundingRadius = 0.388999998569489f; wowPlayerInfo.CombatReach = 1.5f; if ( iGender == 0 ) { wowPlayerInfo.DisplayId = wowCharacterCreateInfo.MaleDisplayId; wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.MaleDisplayId; } else { wowPlayerInfo.DisplayId = wowCharacterCreateInfo.FemaleDisplayId; wowPlayerInfo.NativeDisplayId = wowCharacterCreateInfo.FemaleDisplayId; } wowPlayerInfo.AttackPower = 0; wowPlayerInfo.NextLevelXP = 400; wowPlayerInfo.MaxLevel = 10; for ( uint iIndex = 0; iIndex < DBCInstances.FactionEntry.Count; iIndex++ ) { FactionEntry factionEntry = DBCInstances.FactionEntry.LookupRowEntry( iIndex ); if ( factionEntry == null ) continue; if ( factionEntry.m_RepListId < 0 ) continue; int iReputation = 0; if ( ( factionEntry.m_BaseRepMask1 & ( 1 << ( iRace - 1 ) ) ) != 0 ) { iReputation = (int)factionEntry.m_BaseRepValue1; } else if ( ( factionEntry.m_BaseRepMask2 & ( 1 << ( iRace - 1 ) ) ) != 0 ) { iReputation = (int)factionEntry.m_BaseRepValue2; } else if ( ( factionEntry.m_BaseRepMask3 & ( 1 << ( iRace - 1 ) ) ) != 0 ) { iReputation = (int)factionEntry.m_BaseRepValue3; } else if ( ( factionEntry.m_BaseRepMask4 & ( 1 << ( iRace - 1 ) ) ) != 0 ) { iReputation = (int)factionEntry.m_BaseRepValue4; } else continue; WowReputation wowReputation = new WowReputation() { FactionId = factionEntry.ID, Reputation = iReputation, }; if ( (int)wowReputation.CalcRating() <= (int)WowFactionRating.Hostile ) wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagAtWar; if ( ( factionEntry.m_Team == 469 && wowPlayerInfo.TeamId == WowTeam.ALLIANCE ) || ( factionEntry.m_Team == 67 && wowPlayerInfo.TeamId == WowTeam.HORDE ) ) wowReputation.Flag |= (byte)WowFactionFlag.FactionFlagVisible; wowPlayerInfo.ReputationManager.AddReputation( wowReputation.FactionId, wowReputation ); } foreach ( WowPlayerInfoSkill wowPlayerInfoSkill in wowCharacterCreateInfo.WowPlayerSkills.Skills ) { WowSkillTemplate wowSkillTemplate = ProcessServer.WowZoneCluster.World.GlobalSkillTemplates.GetSkillTemplate( (long)wowPlayerInfoSkill.Skill ) as WowSkillTemplate; if ( wowSkillTemplate == null ) continue; WowSkill wowSkill = new WowSkill() { Serial = wowSkillTemplate.SkillId, SkillTemplate = wowSkillTemplate }; wowPlayerInfo.SkillManager.AddSkill( wowSkill.Serial, wowSkill ); } foreach ( WowPlayerInfoSpell wowPlayerInfoSpell in wowCharacterCreateInfo.WowPlayerSpells.Spells ) { WowSpellTemplate wowSpellTemplate = ProcessServer.WowZoneCluster.World.GlobalSpellTemplates.GetSpellTemplate( (long)wowPlayerInfoSpell.Spell ) as WowSpellTemplate; if ( wowSpellTemplate == null ) continue; WowSpell wowSpell = new WowSpell() { Serial = wowSpellTemplate.SpellId, SpellTemplate = wowSpellTemplate }; wowPlayerInfo.SpellManager.AddSpell( wowSpell.Serial, wowSpell ); } foreach ( WowPlayerInfoItem wowPlayerInfoItem in wowCharacterCreateInfo.WowPlayerItems.Items ) { WowItemTemplate wowItemTemplate = ProcessServer.WowZoneCluster.World.ItemTemplateManager.GetItemTemplate( (long)wowPlayerInfoItem.ItemId ) as WowItemTemplate; if ( wowItemTemplate == null ) continue; WowItemContainer equipmentBag = wowPlayerInfo.BagManager.EquipmentBag; if ( equipmentBag == null ) break; WowItem wowItem = equipmentBag.FindSubItemAtSlot( wowItemTemplate.InventoryType ) as WowItem; if ( wowItem == null ) { wowItem = new WowItem() { ItemTemplate = wowItemTemplate }; equipmentBag.AddSubItem( wowItemTemplate.InventoryType, wowItem ); } else { WowItemContainer mainBag = wowPlayerInfo.BagManager.MainBag; if ( mainBag == null ) break; wowItem = new WowItem() { ItemTemplate = wowItemTemplate }; mainBag.AddToFreeSlot( wowItem ); } } foreach ( WowPlayerInfoAction wowPlayerInfoAction in wowCharacterCreateInfo.WowPlayerActions.Actions ) { WowActionBar wowActionBar = new WowActionBar() { Serial = wowPlayerInfoAction.Button, Action = wowPlayerInfoAction.Action, Type = wowPlayerInfoAction.Type }; wowPlayerInfo.ActionBarManager.AddActionBar( wowActionBar.Serial, wowActionBar ); } if ( wowPlayerInfo.SaveNewCreature() == false ) { netState.Send( new Word_CharCreateResponseError( ResponseCodes.CHAR_CREATE_NAME_IN_USE ) ); return; } ProcessServer.WowZoneCluster.World.GlobalPlayerInfo.AddPlayerInfo( wowPlayerInfo.Name, wowPlayerInfo.Serial, wowPlayerInfo ); netState.Send( new Word_CharCreateResponse() ); }
public async Task <WowItem> GetOrCreateWowItemAsync(InciteDbContext dbContext, WowHeadItem wowHeadItem, Dictionary <int, WowItem> seenItems) { if (seenItems.ContainsKey(wowHeadItem.Id)) { return(seenItems[wowHeadItem.Id]); } WowItem wowItem = await dbContext.WowItems .FirstOrDefaultAsync(x => x.WowId == wowHeadItem.Id); if (wowItem != null) { seenItems[wowHeadItem.Id] = wowItem; return(wowItem); } WowItemSubclass wowItemSubclass = null; WowItemClass wowItemClass = await dbContext.WowItemClasses .Include(x => x.WowItemSubclasses) .FirstOrDefaultAsync(x => x.WowId == wowHeadItem.ItemClass.Id); if (wowItemClass == null) { wowItemClass = new WowItemClass() { WowId = wowHeadItem.ItemClass.Id, Name = wowHeadItem.ItemClass.Name }; wowItemSubclass = new WowItemSubclass() { WowId = wowHeadItem.ItemSubclass.Id, Name = wowHeadItem.ItemSubclass.Name, WowItemClass = wowItemClass, }; dbContext.WowItemClasses.Add(wowItemClass); dbContext.WowItemSubclasses.Add(wowItemSubclass); } else { wowItemSubclass = wowItemClass.WowItemSubclasses .FirstOrDefault(x => x.WowId == wowHeadItem.ItemSubclass.Id); if (wowItemSubclass == null) { wowItemSubclass = new WowItemSubclass() { WowId = wowHeadItem.ItemSubclass.Id, Name = wowHeadItem.ItemSubclass.Name, WowItemClass = wowItemClass, }; dbContext.WowItemSubclasses.Add(wowItemSubclass); } } wowItem = new WowItem() { WowId = wowHeadItem.Id, Name = wowHeadItem.Name, ItemQuality = (WowItemQuality)wowHeadItem.Quality, WowHeadIcon = wowHeadItem.Icon, WowItemClass = wowItemClass, WowItemSubclass = wowItemSubclass, }; seenItems[wowHeadItem.Id] = wowItem; dbContext.Add(wowItem); if (wowHeadItem.CreatedBy.Count > 0) { foreach (var wowHeadSpell in wowHeadItem.CreatedBy) { WowSpell wowSpell = await dbContext.WowSpells .FirstOrDefaultAsync(x => x.WowId == wowHeadSpell.Id); if (wowSpell == null) { wowSpell = new WowSpell() { WowId = wowHeadSpell.Id, Name = wowHeadSpell.Name, CreatedItem = wowItem, }; dbContext.WowSpells.Add(wowSpell); foreach (var reagent in wowHeadSpell.Reagents) { var wowReagent = new WowReagent() { Count = reagent.Count, WowSpell = wowSpell, WowItem = await GetOrCreateWowItemAsync(dbContext, reagent.Item, seenItems), }; dbContext.WowReagents.Add(wowReagent); } } wowItem.CreatedBy.Add(wowSpell); } } await dbContext.SaveChangesAsync(); return(wowItem); }