hondacrx
2023-08-21 07:22:33 -04:00
parent 794ff2bb99
commit f6807e152c
76 changed files with 3149 additions and 2233 deletions
+32 -14
View File
@@ -11,6 +11,7 @@ using Game.Entities;
using Game.Groups;
using Game.Guilds;
using Game.Maps;
using Game.Miscellaneous;
using Game.Networking;
using Game.Networking.Packets;
using Game.Spells;
@@ -85,7 +86,7 @@ namespace Game
charInfo.Customizations.Clear();
if (charInfo.Flags2 != CharacterCustomizeFlags.Customize)
if (!charInfo.Flags2.HasAnyFlag(CharacterCustomizeFlags.Customize | CharacterCustomizeFlags.Faction | CharacterCustomizeFlags.Race))
{
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_ADD_AT_LOGIN_FLAG);
stmt.AddValue(0, (ushort)AtLoginFlags.Customize);
@@ -165,7 +166,7 @@ namespace Game
SendPacket(charEnum);
}
public bool MeetsChrCustomizationReq(ChrCustomizationReqRecord req, Class playerClass, bool checkRequiredDependentChoices, List<ChrCustomizationChoice> selectedChoices)
public bool MeetsChrCustomizationReq(ChrCustomizationReqRecord req, Race race, Class playerClass, bool checkRequiredDependentChoices, List<ChrCustomizationChoice> selectedChoices)
{
if (!req.GetFlags().HasFlag(ChrCustomizationReqFlag.HasRequirements))
return true;
@@ -173,6 +174,10 @@ namespace Game
if (req.ClassMask != 0 && (req.ClassMask & (1 << ((int)playerClass - 1))) == 0)
return false;
var raceMask = new RaceMask<long>(req.RaceMask);
if (race != Race.None && !raceMask.IsEmpty() && raceMask.RawValue != -1 && !raceMask.HasRace(race))
return false;
if (req.AchievementID != 0 /*&& !HasAchieved(req->AchievementID)*/)
return false;
@@ -240,7 +245,7 @@ namespace Game
ChrCustomizationReqRecord req = CliDB.ChrCustomizationReqStorage.LookupByKey(customizationOptionData.ChrCustomizationReqID);
if (req != null)
if (!MeetsChrCustomizationReq(req, playerClass, false, customizations))
if (!MeetsChrCustomizationReq(req, race, playerClass, false, customizations))
return false;
var choicesForOption = Global.DB2Mgr.GetCustomiztionChoices(playerChoice.ChrCustomizationOptionID);
@@ -255,7 +260,7 @@ namespace Game
ChrCustomizationReqRecord reqEntry = CliDB.ChrCustomizationReqStorage.LookupByKey(customizationChoiceData.ChrCustomizationReqID);
if (reqEntry != null)
if (!MeetsChrCustomizationReq(reqEntry, playerClass, true, customizations))
if (!MeetsChrCustomizationReq(reqEntry, race, playerClass, true, customizations))
return false;
}
@@ -374,8 +379,8 @@ namespace Game
return;
}
ulong raceMaskDisabled = WorldConfig.GetUInt64Value(WorldCfg.CharacterCreatingDisabledRacemask);
if (Convert.ToBoolean((ulong)SharedConst.GetMaskForRace(charCreate.CreateInfo.RaceId) & raceMaskDisabled))
RaceMask<ulong> raceMaskDisabled = new(WorldConfig.GetUInt64Value(WorldCfg.CharacterCreatingDisabledRacemask));
if (raceMaskDisabled.HasRace(charCreate.CreateInfo.RaceId))
{
SendCharCreate(ResponseCodes.CharCreateDisabled);
return;
@@ -839,10 +844,6 @@ namespace Game
pCurrChar.SetGuildLevel(0);
}
// Send stable contents to display icons on Call Pet spells
if (pCurrChar.HasSpell(SharedConst.CallPetSpellId))
SendStablePet(ObjectGuid.Empty);
pCurrChar.GetSession().GetBattlePetMgr().SendJournalLockStatus();
pCurrChar.SendInitialPacketsBeforeAddToMap();
@@ -1382,6 +1383,23 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.AlterAppearance)]
void HandleAlterAppearance(AlterApperance packet)
{
if (packet.CustomizedChrModelID != 0)
{
var conditionalChrModel = CliDB.ConditionalChrModelStorage.LookupByKey(packet.CustomizedChrModelID);
if (conditionalChrModel == null)
return;
var req = CliDB.ChrCustomizationReqStorage.LookupByKey(conditionalChrModel.ChrCustomizationReqID);
if (req != null)
if (!MeetsChrCustomizationReq(req, (Race)packet.CustomizedRace, _player.GetClass(), false, packet.Customizations))
return;
var condition = CliDB.PlayerConditionStorage.LookupByKey(conditionalChrModel.PlayerConditionID);
if (condition != null)
if (!ConditionManager.IsPlayerMeetingCondition(_player, condition))
return;
}
if (!ValidateAppearance(_player.GetRace(), _player.GetClass(), (Gender)packet.NewSex, packet.Customizations))
return;
@@ -1766,8 +1784,8 @@ namespace Game
if (!HasPermission(RBACPermissions.SkipCheckCharacterCreationRacemask))
{
ulong raceMaskDisabled = WorldConfig.GetUInt64Value(WorldCfg.CharacterCreatingDisabledRacemask);
if (Convert.ToBoolean((ulong)SharedConst.GetMaskForRace(factionChangeInfo.RaceID) & raceMaskDisabled))
RaceMask<ulong> raceMaskDisabled = new(WorldConfig.GetUInt64Value(WorldCfg.CharacterCreatingDisabledRacemask));
if (raceMaskDisabled.HasRace(factionChangeInfo.RaceID))
{
SendCharFactionChange(ResponseCodes.CharCreateError, factionChangeInfo);
return;
@@ -2078,8 +2096,8 @@ namespace Game
var questTemplates = Global.ObjectMgr.GetQuestTemplates();
foreach (Quest quest in questTemplates.Values)
{
long newRaceMask = (long)(newTeamId == TeamId.Alliance ? SharedConst.RaceMaskAlliance : SharedConst.RaceMaskHorde);
if (quest.AllowableRaces != -1 && !Convert.ToBoolean(quest.AllowableRaces & newRaceMask))
RaceMask<ulong> newRaceMask = newTeamId == TeamId.Alliance ? RaceMask.Alliance : RaceMask.Horde;
if (quest.AllowableRaces.RawValue != unchecked((ulong)-1) && (quest.AllowableRaces & newRaceMask).IsEmpty())
{
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHAR_QUESTSTATUS_REWARDED_ACTIVE_BY_QUEST);
stmt.AddValue(0, lowGuid);
+1 -1
View File
@@ -614,7 +614,7 @@ namespace Game
{
GuildRewardItem rewardItem = new();
rewardItem.ItemID = rewards[i].ItemID;
rewardItem.RaceMask = (uint)rewards[i].RaceMask;
rewardItem.RaceMask = rewards[i].RaceMask;
rewardItem.MinGuildLevel = 0;
rewardItem.MinGuildRep = rewards[i].MinGuildRep;
rewardItem.AchievementsRequired = rewards[i].AchievementsRequired;
+3
View File
@@ -465,6 +465,9 @@ namespace Game
{
if (_player.PlayerTalkClass.GetInteractionData().SourceGuid == closeInteraction.SourceGuid)
_player.PlayerTalkClass.GetInteractionData().Reset();
if (_player.GetStableMaster() == closeInteraction.SourceGuid)
_player.SetStableMaster(ObjectGuid.Empty);
}
[WorldPacketHandler(ClientOpcodes.ConversationLineStarted)]
+3 -188
View File
@@ -324,61 +324,10 @@ namespace Game
if (GetPlayer().IsMounted())
GetPlayer().RemoveAurasByType(AuraType.Mounted);
SendStablePet(packet.StableMaster);
_player.SetStableMaster(packet.StableMaster);
}
public void SendStablePet(ObjectGuid guid)
{
PetStableList packet = new();
packet.StableMaster = guid;
PetStable petStable = GetPlayer().GetPetStable();
if (petStable == null)
{
SendPacket(packet);
return;
}
for (uint petSlot = 0; petSlot < petStable.ActivePets.Length; ++petSlot)
{
if (petStable.ActivePets[petSlot] == null)
continue;
PetStable.PetInfo pet = petStable.ActivePets[petSlot];
PetStableInfo stableEntry;
stableEntry.PetSlot = petSlot + (int)PetSaveMode.FirstActiveSlot;
stableEntry.PetNumber = pet.PetNumber;
stableEntry.CreatureID = pet.CreatureId;
stableEntry.DisplayID = pet.DisplayId;
stableEntry.ExperienceLevel = pet.Level;
stableEntry.PetFlags = PetStableinfo.Active;
stableEntry.PetName = pet.Name;
packet.Pets.Add(stableEntry);
}
for (uint petSlot = 0; petSlot < petStable.StabledPets.Length; ++petSlot)
{
if (petStable.StabledPets[petSlot] == null)
continue;
PetStable.PetInfo pet = petStable.StabledPets[petSlot];
PetStableInfo stableEntry;
stableEntry.PetSlot = petSlot + (int)PetSaveMode.FirstStableSlot;
stableEntry.PetNumber = pet.PetNumber;
stableEntry.CreatureID = pet.CreatureId;
stableEntry.DisplayID = pet.DisplayId;
stableEntry.ExperienceLevel = pet.Level;
stableEntry.PetFlags = PetStableinfo.Inactive;
stableEntry.PetName = pet.Name;
packet.Pets.Add(stableEntry);
}
SendPacket(packet);
}
void SendPetStableResult(StableResult result)
public void SendPetStableResult(StableResult result)
{
PetStableResult petStableResult = new();
petStableResult.Result = result;
@@ -394,141 +343,7 @@ namespace Game
return;
}
GetPlayer().RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Interacting);
PetStable petStable = GetPlayer().GetPetStable();
if (petStable == null)
{
SendPetStableResult(StableResult.InternalError);
return;
}
(PetStable.PetInfo srcPet, PetSaveMode srcPetSlot) = Pet.GetLoadPetInfo(petStable, 0, setPetSlot.PetNumber, null);
PetSaveMode dstPetSlot = (PetSaveMode)setPetSlot.DestSlot;
PetStable.PetInfo dstPet = Pet.GetLoadPetInfo(petStable, 0, 0, dstPetSlot).Item1;
if (srcPet == null || srcPet.Type != PetType.Hunter)
{
SendPetStableResult(StableResult.InternalError);
return;
}
if (dstPet != null && dstPet.Type != PetType.Hunter)
{
SendPetStableResult(StableResult.InternalError);
return;
}
PetStable.PetInfo src = null;
PetStable.PetInfo dst = null;
PetSaveMode? newActivePetIndex = null;
if (SharedConst.IsActivePetSlot(srcPetSlot) && SharedConst.IsActivePetSlot(dstPetSlot))
{
// active<.active: only swap ActivePets and CurrentPetIndex (do not despawn pets)
src = petStable.ActivePets[srcPetSlot - PetSaveMode.FirstActiveSlot];
dst = petStable.ActivePets[dstPetSlot - PetSaveMode.FirstActiveSlot];
if (petStable.GetCurrentActivePetIndex().Value == (uint)srcPetSlot)
newActivePetIndex = dstPetSlot;
else if (petStable.GetCurrentActivePetIndex().Value == (uint)dstPetSlot)
newActivePetIndex = srcPetSlot;
}
else if (SharedConst.IsStabledPetSlot(srcPetSlot) && SharedConst.IsStabledPetSlot(dstPetSlot))
{
// stabled<.stabled: only swap StabledPets
src = petStable.StabledPets[srcPetSlot - PetSaveMode.FirstStableSlot];
dst = petStable.StabledPets[dstPetSlot - PetSaveMode.FirstStableSlot];
}
else if (SharedConst.IsActivePetSlot(srcPetSlot) && SharedConst.IsStabledPetSlot(dstPetSlot))
{
// active<.stabled: swap petStable contents and despawn active pet if it is involved in swap
if (petStable.CurrentPetIndex.Value == (uint)srcPetSlot)
{
Pet oldPet = _player.GetPet();
if (oldPet != null && !oldPet.IsAlive())
{
SendPetStableResult(StableResult.InternalError);
return;
}
_player.RemovePet(oldPet, PetSaveMode.NotInSlot);
}
if (dstPet != null)
{
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(dstPet.CreatureId);
if (creatureInfo == null || !creatureInfo.IsTameable(_player.CanTameExoticPets(), creatureInfo.GetDifficulty(Difficulty.None)))
{
SendPetStableResult(StableResult.CantControlExotic);
return;
}
}
src = petStable.ActivePets[srcPetSlot - PetSaveMode.FirstActiveSlot];
dst = petStable.StabledPets[dstPetSlot - PetSaveMode.FirstStableSlot];
}
else if (SharedConst.IsStabledPetSlot(srcPetSlot) && SharedConst.IsActivePetSlot(dstPetSlot))
{
// stabled<.active: swap petStable contents and despawn active pet if it is involved in swap
if (petStable.CurrentPetIndex.Value == (uint)dstPetSlot)
{
Pet oldPet = _player.GetPet();
if (oldPet != null && !oldPet.IsAlive())
{
SendPetStableResult(StableResult.InternalError);
return;
}
_player.RemovePet(oldPet, PetSaveMode.NotInSlot);
}
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(srcPet.CreatureId);
if (creatureInfo == null || !creatureInfo.IsTameable(_player.CanTameExoticPets(), creatureInfo.GetDifficulty(Difficulty.None)))
{
SendPetStableResult(StableResult.CantControlExotic);
return;
}
src = petStable.StabledPets[srcPetSlot - PetSaveMode.FirstStableSlot];
dst = petStable.ActivePets[dstPetSlot - PetSaveMode.FirstActiveSlot];
}
SQLTransaction trans = new();
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_ID);
stmt.AddValue(0, (short)dstPetSlot);
stmt.AddValue(1, _player.GetGUID().GetCounter());
stmt.AddValue(2, srcPet.PetNumber);
trans.Append(stmt);
if (dstPet != null)
{
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_ID);
stmt.AddValue(0, (short)srcPetSlot);
stmt.AddValue(1, _player.GetGUID().GetCounter());
stmt.AddValue(2, dstPet.PetNumber);
trans.Append(stmt);
}
AddTransactionCallback(DB.Characters.AsyncCommitTransaction(trans)).AfterComplete(success =>
{
var currentPlayerGuid = _player.GetGUID();
if (_player && _player.GetGUID() == currentPlayerGuid)
{
if (success)
{
Extensions.Swap(ref src, ref dst);
if (newActivePetIndex.HasValue)
GetPlayer().GetPetStable().SetCurrentActivePetIndex((uint)newActivePetIndex.Value);
SendPetStableResult(StableResult.StableSuccess);
}
else
{
SendPetStableResult(StableResult.InternalError);
}
}
});
_player.SetPetSlot(setPetSlot.PetNumber, (PetSaveMode)setPetSlot.DestSlot);
}
[WorldPacketHandler(ClientOpcodes.RepairItem, Processing = PacketProcessing.Inplace)]
-3
View File
@@ -582,9 +582,6 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.PetAbandon)]
void HandlePetAbandon(PetAbandon packet)
{
if (!GetPlayer().IsInWorld)
return;
// pet/charmed
Creature pet = ObjectAccessor.GetCreatureOrPetOrVehicle(GetPlayer(), packet.Pet);
if (pet && pet.ToPet() && pet.ToPet().GetPetType() == PetType.Hunter)
+1 -1
View File
@@ -80,7 +80,7 @@ namespace Game
continue;
// check if race matches racemask
if (!Convert.ToBoolean(request.RaceFilter & (1 << target.Race)))
if (!request.RaceFilter.HasRace((Race)target.Race))
continue;
if (!whoRequest.Areas.Empty())
+1 -1
View File
@@ -81,7 +81,7 @@ namespace Game
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo((uint)effect.SpellID, user.GetMap().GetDifficultyID());
if (spellInfo != null)
{
if (!spellInfo.CanBeUsedInCombat())
if (!spellInfo.CanBeUsedInCombat(user))
{
user.SendEquipError(InventoryResult.NotInCombat, item);
return;