Core/Entities: don't allow client control if player is still affected by any lose of control state

Port From (https://github.com/TrinityCore/TrinityCore/commit/d0f4310c4417fb5dc8e89061adf4ce113caa4227)
This commit is contained in:
hondacrx
2021-06-23 14:39:59 -04:00
parent 84d05548f2
commit a34469c171
6 changed files with 117 additions and 124 deletions
+3 -3
View File
@@ -722,9 +722,9 @@ namespace Game.AI
{ {
foreach (var seat in vehicle.Seats) foreach (var seat in vehicle.Seats)
{ {
Player player1 = Global.ObjAccessor.GetPlayer(unit, seat.Value.Passenger.Guid); Player passenger = Global.ObjAccessor.GetPlayer(unit, seat.Value.Passenger.Guid);
if (player1 != null) if (passenger != null)
player1.GroupEventHappens(e.Action.quest.questId, GetBaseObject()); passenger.GroupEventHappens(e.Action.quest.questId, GetBaseObject());
} }
} }
break; break;
+2 -2
View File
@@ -764,8 +764,8 @@ namespace Game.Chat
if (exclaim) if (exclaim)
{ {
ChannelNameBuilder ownerChangedBuilder = new(this, new OwnerChangedAppend(_ownerGuid)); ChannelNameBuilder ownerBuilder = new(this, new OwnerChangedAppend(_ownerGuid));
SendToAll(ownerChangedBuilder); SendToAll(ownerBuilder);
} }
UpdateChannelInDB(); UpdateChannelInDB();
+90 -96
View File
@@ -30,7 +30,7 @@ namespace Game.Chat
[CommandGroup("lookup", RBACPermissions.CommandLookup, true)] [CommandGroup("lookup", RBACPermissions.CommandLookup, true)]
class LookupCommands class LookupCommands
{ {
static int maxlookup = 50; static int maxResults = 50;
[Command("area", RBACPermissions.CommandLookupArea, true)] [Command("area", RBACPermissions.CommandLookupArea, true)]
static bool Area(StringArguments args, CommandHandler handler) static bool Area(StringArguments args, CommandHandler handler)
@@ -70,9 +70,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -121,9 +121,9 @@ namespace Game.Chat
if (name.Like(namePart)) if (name.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -146,9 +146,9 @@ namespace Game.Chat
if (_name.Like(namePart)) if (_name.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -192,9 +192,9 @@ namespace Game.Chat
if (descr.Like(namePart)) if (descr.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -259,9 +259,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -330,9 +330,9 @@ namespace Game.Chat
if (name.Like(namePart)) if (name.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -390,9 +390,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -437,9 +437,9 @@ namespace Game.Chat
if (name.Like(namePart)) if (name.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -462,9 +462,9 @@ namespace Game.Chat
if (_name.Like(namePart)) if (_name.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -502,72 +502,66 @@ namespace Game.Chat
foreach (var qInfo in qTemplates.Values) foreach (var qInfo in qTemplates.Values)
{ {
int localeIndex = handler.GetSessionDbLocaleIndex(); int localeIndex = handler.GetSessionDbLocaleIndex();
if (localeIndex >= 0) QuestTemplateLocale questLocale = Global.ObjectMgr.GetQuestLocale(qInfo.Id);
if (questLocale != null)
{ {
byte ulocaleIndex = (byte)localeIndex; if (questLocale.LogTitle.Length > localeIndex && !questLocale.LogTitle[localeIndex].IsEmpty())
QuestTemplateLocale questLocale = Global.ObjectMgr.GetQuestLocale(qInfo.Id);
if (questLocale != null)
{ {
if (questLocale.LogTitle.Length > ulocaleIndex && !string.IsNullOrEmpty(questLocale.LogTitle[ulocaleIndex])) string title = questLocale.LogTitle[localeIndex];
if (title.Like(namePart))
{ {
string title = questLocale.LogTitle[ulocaleIndex]; if (maxResults != 0 && count++ == maxResults)
if (title.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
{ return true;
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup);
return true;
}
string statusStr = "";
if (target)
{
QuestStatus status = target.GetQuestStatus(qInfo.Id);
switch (status)
{
case QuestStatus.Complete:
statusStr = handler.GetCypherString(CypherStrings.CommandQuestComplete);
break;
case QuestStatus.Incomplete:
statusStr = handler.GetCypherString(CypherStrings.CommandQuestActive);
break;
case QuestStatus.Rewarded:
statusStr = handler.GetCypherString(CypherStrings.CommandQuestRewarded);
break;
default:
break;
}
}
if (handler.GetSession() != null)
{
int maxLevel = 0;
var questLevels = Global.DB2Mgr.GetContentTuningData(qInfo.ContentTuningId, handler.GetSession().GetPlayer().m_playerData.CtrOptions.GetValue().ContentTuningConditionMask);
if (questLevels.HasValue)
maxLevel = questLevels.Value.MaxLevel;
int scalingFactionGroup = 0;
ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(qInfo.ContentTuningId);
if (contentTuning != null)
scalingFactionGroup = contentTuning.GetScalingFactionGroup();
handler.SendSysMessage(CypherStrings.QuestListChat, qInfo.Id, qInfo.Id,
handler.GetSession().GetPlayer().GetQuestLevel(qInfo),
handler.GetSession().GetPlayer().GetQuestMinLevel(qInfo),
maxLevel, scalingFactionGroup,
title, statusStr);
}
else
handler.SendSysMessage(CypherStrings.QuestListConsole, qInfo.Id, title, statusStr);
if (!found)
found = true;
continue;
} }
string statusStr = "";
if (target)
{
switch (target.GetQuestStatus(qInfo.Id))
{
case QuestStatus.Complete:
statusStr = handler.GetCypherString(CypherStrings.CommandQuestComplete);
break;
case QuestStatus.Incomplete:
statusStr = handler.GetCypherString(CypherStrings.CommandQuestActive);
break;
case QuestStatus.Rewarded:
statusStr = handler.GetCypherString(CypherStrings.CommandQuestRewarded);
break;
default:
break;
}
}
if (handler.GetSession() != null)
{
int maxLevel = 0;
var questLevels = Global.DB2Mgr.GetContentTuningData(qInfo.ContentTuningId, handler.GetSession().GetPlayer().m_playerData.CtrOptions.GetValue().ContentTuningConditionMask);
if (questLevels.HasValue)
maxLevel = questLevels.Value.MaxLevel;
int scalingFactionGroup = 0;
ContentTuningRecord contentTuning = CliDB.ContentTuningStorage.LookupByKey(qInfo.ContentTuningId);
if (contentTuning != null)
scalingFactionGroup = contentTuning.GetScalingFactionGroup();
handler.SendSysMessage(CypherStrings.QuestListChat, qInfo.Id, qInfo.Id,
handler.GetSession().GetPlayer().GetQuestLevel(qInfo),
handler.GetSession().GetPlayer().GetQuestMinLevel(qInfo),
maxLevel, scalingFactionGroup,
title, statusStr);
}
else
handler.SendSysMessage(CypherStrings.QuestListConsole, qInfo.Id, title, statusStr);
if (!found)
found = true;
continue;
} }
} }
} }
@@ -578,9 +572,9 @@ namespace Game.Chat
if (_title.Like(namePart)) if (_title.Like(namePart))
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -678,9 +672,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -737,9 +731,9 @@ namespace Game.Chat
if (!name.Like(namePart)) if (!name.Like(namePart))
continue; continue;
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -781,7 +775,7 @@ namespace Game.Chat
if (!tele.Value.name.Like(namePart)) if (!tele.Value.name.Like(namePart))
continue; continue;
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
limitReached = true; limitReached = true;
break; break;
@@ -799,7 +793,7 @@ namespace Game.Chat
handler.SendSysMessage(CypherStrings.CommandTeleLocation, reply.ToString()); handler.SendSysMessage(CypherStrings.CommandTeleLocation, reply.ToString());
if (limitReached) if (limitReached)
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -851,9 +845,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && counter == maxlookup) if (maxResults != 0 && counter == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -918,9 +912,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && counter == maxlookup) if (maxResults != 0 && counter == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
@@ -1035,9 +1029,9 @@ namespace Game.Chat
uint count = 0; uint count = 0;
do do
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
uint accountId = result.Read<uint>(0); uint accountId = result.Read<uint>(0);
@@ -1120,9 +1114,9 @@ namespace Game.Chat
if (locale < Locale.Total) if (locale < Locale.Total)
{ {
if (maxlookup != 0 && count++ == maxlookup) if (maxResults != 0 && count++ == maxResults)
{ {
handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxlookup); handler.SendSysMessage(CypherStrings.CommandLookupMaxResults, maxResults);
return true; return true;
} }
+12 -12
View File
@@ -68,7 +68,7 @@ namespace Game.Entities
if (petition == null) if (petition == null)
continue; continue;
petition.AddSignature(petition.PetitionGuid, result.Read<uint>(1), ObjectGuid.Create(HighGuid.Player, result.Read<ulong>(2)), true); petition.AddSignature(result.Read<uint>(1), ObjectGuid.Create(HighGuid.Player, result.Read<ulong>(2)), true);
++count; ++count;
} while (result.NextRow()); } while (result.NextRow());
@@ -80,8 +80,8 @@ namespace Game.Entities
Petition p = new(); Petition p = new();
p.PetitionGuid = petitionGuid; p.PetitionGuid = petitionGuid;
p.ownerGuid = ownerGuid; p.ownerGuid = ownerGuid;
p.petitionName = name; p.PetitionName = name;
p.signatures.Clear(); p.Signatures.Clear();
_petitionStorage[petitionGuid] = p; _petitionStorage[petitionGuid] = p;
@@ -160,28 +160,28 @@ namespace Game.Entities
{ {
public ObjectGuid PetitionGuid; public ObjectGuid PetitionGuid;
public ObjectGuid ownerGuid; public ObjectGuid ownerGuid;
public string petitionName; public string PetitionName;
public List<(uint AccountId, ObjectGuid PlayerGuid)> signatures = new(); public List<(uint AccountId, ObjectGuid PlayerGuid)> Signatures = new();
public bool IsPetitionSignedByAccount(uint accountId) public bool IsPetitionSignedByAccount(uint accountId)
{ {
foreach (var signature in signatures) foreach (var signature in Signatures)
if (signature.AccountId == accountId) if (signature.AccountId == accountId)
return true; return true;
return false; return false;
} }
public void AddSignature(ObjectGuid petitionGuid, uint accountId, ObjectGuid playerGuid, bool isLoading) public void AddSignature(uint accountId, ObjectGuid playerGuid, bool isLoading)
{ {
signatures.Add((accountId, playerGuid)); Signatures.Add((accountId, playerGuid));
if (isLoading) if (isLoading)
return; return;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PETITION_SIGNATURE); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_PETITION_SIGNATURE);
stmt.AddValue(0, ownerGuid.GetCounter()); stmt.AddValue(0, ownerGuid.GetCounter());
stmt.AddValue(1, petitionGuid.GetCounter()); stmt.AddValue(1, PetitionGuid.GetCounter());
stmt.AddValue(2, playerGuid.GetCounter()); stmt.AddValue(2, playerGuid.GetCounter());
stmt.AddValue(3, accountId); stmt.AddValue(3, accountId);
@@ -190,7 +190,7 @@ namespace Game.Entities
public void UpdateName(string newName) public void UpdateName(string newName)
{ {
petitionName = newName; PetitionName = newName;
PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_PETITION_NAME); PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.UPD_PETITION_NAME);
stmt.AddValue(0, newName); stmt.AddValue(0, newName);
@@ -200,11 +200,11 @@ namespace Game.Entities
public void RemoveSignatureBySigner(ObjectGuid playerGuid) public void RemoveSignatureBySigner(ObjectGuid playerGuid)
{ {
foreach (var itr in signatures) foreach (var itr in Signatures)
{ {
if (itr.PlayerGuid == playerGuid) if (itr.PlayerGuid == playerGuid)
{ {
signatures.Remove(itr); Signatures.Remove(itr);
// notify owner // notify owner
Player owner = Global.ObjAccessor.FindConnectedPlayer(ownerGuid); Player owner = Global.ObjAccessor.FindConnectedPlayer(ownerGuid);
+6 -6
View File
@@ -132,7 +132,7 @@ namespace Game
signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(petition.ownerGuid)); signaturesPacket.OwnerAccountID = ObjectGuid.Create(HighGuid.WowAccount, Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(petition.ownerGuid));
signaturesPacket.PetitionID = (int)petition.PetitionGuid.GetCounter(); signaturesPacket.PetitionID = (int)petition.PetitionGuid.GetCounter();
foreach (var signature in petition.signatures) foreach (var signature in petition.Signatures)
{ {
ServerPetitionShowSignatures.PetitionSignature signaturePkt = new(); ServerPetitionShowSignatures.PetitionSignature signaturePkt = new();
signaturePkt.Signer = signature.PlayerGuid; signaturePkt.Signer = signature.PlayerGuid;
@@ -170,7 +170,7 @@ namespace Game
petitionInfo.Petitioner = petition.ownerGuid; petitionInfo.Petitioner = petition.ownerGuid;
petitionInfo.MinSignatures = reqSignatures; petitionInfo.MinSignatures = reqSignatures;
petitionInfo.MaxSignatures = reqSignatures; petitionInfo.MaxSignatures = reqSignatures;
petitionInfo.Title = petition.petitionName; petitionInfo.Title = petition.PetitionName;
responsePacket.Allow = true; responsePacket.Allow = true;
responsePacket.Info = petitionInfo; responsePacket.Info = petitionInfo;
@@ -223,7 +223,7 @@ namespace Game
} }
ObjectGuid ownerGuid = petition.ownerGuid; ObjectGuid ownerGuid = petition.ownerGuid;
int signs = petition.signatures.Count; int signs = petition.Signatures.Count;
if (ownerGuid == GetPlayer().GetGUID()) if (ownerGuid == GetPlayer().GetGUID())
return; return;
@@ -272,7 +272,7 @@ namespace Game
} }
// fill petition store // fill petition store
petition.AddSignature(packet.PetitionGUID, GetAccountId(), _player.GetGUID(), false); petition.AddSignature(GetAccountId(), _player.GetGUID(), false);
Log.outDebug(LogFilter.Network, "PETITION SIGN: {0} by player: {1} ({2} Account: {3})", packet.PetitionGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString(), GetAccountId()); Log.outDebug(LogFilter.Network, "PETITION SIGN: {0} by player: {1} ({2} Account: {3})", packet.PetitionGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString(), GetAccountId());
@@ -360,7 +360,7 @@ namespace Game
return; return;
} }
string name = petition.petitionName; // we need a copy, Guild::AddMember invalidates petition string name = petition.PetitionName; // we need a copy, Guild::AddMember invalidates petition
// Only the petition owner can turn in the petition // Only the petition owner can turn in the petition
if (GetPlayer().GetGUID() != petition.ownerGuid) if (GetPlayer().GetGUID() != petition.ownerGuid)
@@ -383,7 +383,7 @@ namespace Game
return; return;
} }
var signatures = petition.signatures; // we need a copy, Guild::AddMember invalidates petition var signatures = petition.Signatures; // we need a copy, Guild::AddMember invalidates petition
uint requiredSignatures = WorldConfig.GetUIntValue(WorldCfg.MinPetitionSigns); uint requiredSignatures = WorldConfig.GetUIntValue(WorldCfg.MinPetitionSigns);
// Notify player if signatures are missing // Notify player if signatures are missing
+4 -5
View File
@@ -2698,15 +2698,15 @@ namespace Game.Spells
// This prevents spells such as Hunter's Mark from triggering pet attack // This prevents spells such as Hunter's Mark from triggering pet attack
if (m_spellInfo.DmgClass != SpellDmgClass.None) if (m_spellInfo.DmgClass != SpellDmgClass.None)
{ {
Unit unitTarget = m_targets.GetUnitTarget(); Unit target = m_targets.GetUnitTarget();
if (unitTarget) if (target != null)
{ {
foreach (Unit controlled in playerCaster.m_Controlled) foreach (Unit controlled in playerCaster.m_Controlled)
{ {
Creature cControlled = controlled.ToCreature(); Creature cControlled = controlled.ToCreature();
if (cControlled != null) if (cControlled != null)
if (cControlled.IsAIEnabled) if (cControlled.IsAIEnabled)
cControlled.GetAI().OwnerAttacked(unitTarget); cControlled.GetAI().OwnerAttacked(target);
} }
} }
} }
@@ -2784,8 +2784,7 @@ namespace Game.Spells
if (aura_effmask != 0) if (aura_effmask != 0)
{ {
DiminishingGroup diminishGroup = m_spellInfo.GetDiminishingReturnsGroupForSpell(); if (m_spellInfo.GetDiminishingReturnsGroupForSpell() != 0)
if (diminishGroup != 0)
{ {
DiminishingReturnsType type = m_spellInfo.GetDiminishingReturnsGroupType(); DiminishingReturnsType type = m_spellInfo.GetDiminishingReturnsGroupType();
if (type == DiminishingReturnsType.All || (type == DiminishingReturnsType.Player && target.IsAffectedByDiminishingReturns())) if (type == DiminishingReturnsType.All || (type == DiminishingReturnsType.Player && target.IsAffectedByDiminishingReturns()))