Core/Battlegrounds: Move to scripts And a lot of misc commits i couldn't recover.

Port From (https://github.com/TrinityCore/TrinityCore/commit/d0d5d309bb5877dc2fcb27f6cb123707a31ec1e8)
This commit is contained in:
Hondacrx
2024-08-04 15:18:22 -04:00
parent bca02a24b0
commit e9b21a91be
139 changed files with 8322 additions and 8700 deletions
+2 -4
View File
@@ -161,10 +161,8 @@ namespace Game
if (artifactAppearanceSet == null || artifactAppearanceSet.ArtifactID != artifact.GetTemplate().GetArtifactID())
return;
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(artifactAppearance.UnlockPlayerConditionID);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(_player, playerCondition))
return;
if (!ConditionManager.IsPlayerMeetingCondition(_player, artifactAppearance.UnlockPlayerConditionID))
return;
artifact.SetAppearanceModId(artifactAppearance.ItemAppearanceModifierID);
artifact.SetModifier(ItemModifier.ArtifactAppearanceId, artifactAppearance.Id);
+25 -6
View File
@@ -36,7 +36,7 @@ namespace Game
realmListTicket.Ticket.WriteCString("WorldserverRealmListTicket");
SendPacket(realmListTicket);
}
}
public void SendBattlenetResponse(uint serviceHash, uint methodId, uint token, IMessage response)
{
@@ -52,7 +52,7 @@ namespace Game
SendPacket(bnetResponse);
}
public void SendBattlenetResponse(uint serviceHash, uint methodId, uint token, BattlenetRpcErrorCode status)
public void SendBattlenetResponse(uint serviceHash, uint methodId, uint token, BattlenetRpcErrorCode status)
{
Response bnetResponse = new();
bnetResponse.BnetStatus = status;
@@ -63,16 +63,35 @@ namespace Game
SendPacket(bnetResponse);
}
public void SendBattlenetRequest(uint serviceHash, uint methodId, IMessage request, Action<CodedInputStream> callback)
public void SendBattlenetRequest(OriginalHash serviceHash, uint methodId, IMessage request, bool client, bool server, Action<CodedInputStream> callback)
{
_battlenetResponseCallbacks[_battlenetRequestToken] = callback;
SendBattlenetRequest(serviceHash, methodId, request);
SendBattlenetRequest(serviceHash, methodId, request, client, server);
}
public void SendBattlenetRequest(uint serviceHash, uint methodId, IMessage request)
public void SendBattlenetRequest(NameHash serviceHash, uint methodId, IMessage request, bool client, bool server, Action<CodedInputStream> callback)
{
_battlenetResponseCallbacks[_battlenetRequestToken] = callback;
SendBattlenetRequest(serviceHash, methodId, request, client, server);
}
public void SendBattlenetRequest(OriginalHash serviceHash, uint methodId, IMessage request, bool client = true, bool server = true)
{
Notification notification = new();
notification.Method.Type = MathFunctions.MakePair64(methodId, serviceHash);
notification.Method.Type = MathFunctions.MakePair64(methodId | (client ? 0x40000000 : 0u) | (server ? 0x80000000 : 0u), (uint)serviceHash);
notification.Method.ObjectId = 1;
notification.Method.Token = _battlenetRequestToken++;
if (request.CalculateSize() != 0)
notification.Data.WriteBytes(request.ToByteArray());
SendPacket(notification);
}
public void SendBattlenetRequest(NameHash serviceHash, uint methodId, IMessage request, bool client = true, bool server = true)
{
Notification notification = new();
notification.Method.Type = MathFunctions.MakePair64(methodId | (client ? 0x40000000 : 0u) | (server ? 0x80000000 : 0u), (uint)serviceHash);
notification.Method.ObjectId = 1;
notification.Method.Token = _battlenetRequestToken++;
+4 -8
View File
@@ -1394,10 +1394,8 @@ namespace Game
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 (!ConditionManager.IsPlayerMeetingCondition(_player, (uint)conditionalChrModel.PlayerConditionID))
return;
}
if (!ValidateAppearance(_player.GetRace(), _player.GetClass(), (Gender)packet.NewSex, packet.Customizations))
@@ -1632,10 +1630,8 @@ namespace Game
if (illusion.ItemVisual == 0 || !illusion.HasFlag(SpellItemEnchantmentFlags.AllowTransmog))
return false;
PlayerConditionRecord condition = CliDB.PlayerConditionStorage.LookupByKey(illusion.TransmogUseConditionID);
if (condition != null)
if (!ConditionManager.IsPlayerMeetingCondition(_player, condition))
return false;
if (!ConditionManager.IsPlayerMeetingCondition(_player, illusion.TransmogUseConditionID))
return false;
if (illusion.ScalingClassRestricted > 0 && illusion.ScalingClassRestricted != (byte)_player.GetClass())
return false;
+2 -7
View File
@@ -251,9 +251,6 @@ namespace Game
return;
}
Battleground bg = player.GetBattleground();
if (bg != null)
bg.HandleAreaTrigger(player, packet.AreaTriggerID, packet.Entered);
OutdoorPvP pvp = player.GetOutdoorPvP();
if (pvp != null)
@@ -452,10 +449,8 @@ namespace Game
UISplashScreenRecord splashScreen = null;
foreach (var itr in CliDB.UISplashScreenStorage.Values)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(itr.CharLevelConditionID);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(_player, playerCondition))
continue;
if (!ConditionManager.IsPlayerMeetingCondition(_player, (uint)itr.CharLevelConditionID))
continue;
splashScreen = itr;
}
+1 -2
View File
@@ -756,8 +756,7 @@ namespace Game
// far teleport case
if (GetPlayer().GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Flight)
{
FlightPathMovementGenerator flight = GetPlayer().GetMotionMaster().GetCurrentMovementGenerator() as FlightPathMovementGenerator;
if (flight != null)
if (GetPlayer().GetMotionMaster().GetCurrentMovementGenerator() is FlightPathMovementGenerator flight)
{
bool shouldTeleport = curDestNode != null && curDestNode.ContinentID != GetPlayer().GetMapId();
if (!shouldTeleport)
+2 -4
View File
@@ -440,10 +440,8 @@ namespace Game
VendorItemPkt item = new();
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(vendorItem.PlayerConditionId);
if (playerCondition != null)
if (!ConditionManager.IsPlayerMeetingCondition(_player, playerCondition))
item.PlayerConditionFailed = (int)playerCondition.Id;
if (!ConditionManager.IsPlayerMeetingCondition(_player, vendorItem.PlayerConditionId))
item.PlayerConditionFailed = (int)vendorItem.PlayerConditionId;
if (vendorItem.Type == ItemVendorType.Item)
{
+8 -5
View File
@@ -348,10 +348,6 @@ namespace Game
{
if (GetPlayer().CanRewardQuest(quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID, true)) // Then check if player can receive the reward item (if inventory is not full, if player doesn't have too many unique items, and so on). If not, the client will close the gossip window
{
Battleground bg = _player.GetBattleground();
if (bg != null)
bg.HandleQuestComplete(packet.QuestID, _player);
GetPlayer().RewardQuest(quest, packet.Choice.LootItemType, packet.Choice.Item.ItemID, obj);
}
}
@@ -650,13 +646,20 @@ namespace Game
continue;
}
if (!receiver.SatisfyQuestReputation(quest, false))
if (!receiver.SatisfyQuestMinReputation(quest, false))
{
sender.SendPushToPartyResponse(receiver, QuestPushReason.LowFaction);
receiver.SendPushToPartyResponse(sender, QuestPushReason.LowFactionToRecipient, quest);
continue;
}
if (!receiver.SatisfyQuestMaxReputation(quest, false))
{
sender.SendPushToPartyResponse(receiver, QuestPushReason.HighFaction);
receiver.SendPushToPartyResponse(sender, QuestPushReason.HighFactionToRecipient, quest);
continue;
}
if (!receiver.SatisfyQuestDependentQuests(quest, false))
{
sender.SendPushToPartyResponse(receiver, QuestPushReason.Prerequisite);
+2 -11
View File
@@ -191,15 +191,7 @@ namespace Game
var mountDisplays = Global.DB2Mgr.GetMountDisplays(mount.Id);
if (mountDisplays != null)
{
List<MountXDisplayRecord> usableDisplays = mountDisplays.Where(mountDisplay =>
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(mountDisplay.PlayerConditionID);
if (playerCondition != null)
return ConditionManager.IsPlayerMeetingCondition(GetPlayer(), playerCondition);
return true;
}).ToList();
List<MountXDisplayRecord> usableDisplays = mountDisplays.Where(mountDisplay => ConditionManager.IsPlayerMeetingCondition(GetPlayer(), mountDisplay.PlayerConditionID)).ToList();
if (!usableDisplays.Empty())
preferredMountDisplay = usableDisplays.SelectRandom().CreatureDisplayInfoID;
}
@@ -221,8 +213,7 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.TaxiRequestEarlyLanding, Processing = PacketProcessing.ThreadSafe)]
void HandleTaxiRequestEarlyLanding(TaxiRequestEarlyLanding taxiRequestEarlyLanding)
{
FlightPathMovementGenerator flight = GetPlayer().GetMotionMaster().GetCurrentMovementGenerator() as FlightPathMovementGenerator;
if (flight != null)
if (GetPlayer().GetMotionMaster().GetCurrentMovementGenerator() is FlightPathMovementGenerator flight)
{
if (GetPlayer().m_taxi.RequestEarlyLanding())
{
@@ -129,14 +129,10 @@ namespace Game
return;
}
var condition = CliDB.PlayerConditionStorage.LookupByKey(illusion.UnlockConditionID);
if (condition != null)
if (!ConditionManager.IsPlayerMeetingCondition(player, (uint)illusion.UnlockConditionID))
{
if (!ConditionManager.IsPlayerMeetingCondition(player, condition))
{
Log.outDebug(LogFilter.Network, "WORLD: HandleTransmogrifyItems - {0}, Name: {1} tried to transmogrify illusion using not allowed enchant ({2}).", player.GetGUID().ToString(), player.GetName(), transmogItem.SpellItemEnchantmentID);
return;
}
Log.outDebug(LogFilter.Network, "WORLD: HandleTransmogrifyItems - {0}, Name: {1} tried to transmogrify illusion using not allowed enchant ({2}).", player.GetGUID().ToString(), player.GetName(), transmogItem.SpellItemEnchantmentID);
return;
}
illusionItems[itemTransmogrified] = (uint)transmogItem.SpellItemEnchantmentID;