More refactoring of code.

This commit is contained in:
hondacrx
2019-09-23 21:41:13 -04:00
parent 2418715800
commit 570aebce26
176 changed files with 2261 additions and 2265 deletions
+3 -3
View File
@@ -112,7 +112,7 @@ namespace Game.Entities
if (_group)
{
// 2. In case when player is in group, initialize variables necessary for group calculations:
for (GroupReference refe = _group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = _group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player member = refe.GetSource();
if (member)
@@ -258,11 +258,11 @@ namespace Game.Entities
if (!_isBattleground)
{
// 3.1.2. Alter group rate if group is in raid (not for Battlegrounds).
bool isRaid = !_isPvP && CliDB.MapStorage.LookupByKey(_killer.GetMapId()).IsRaid() && _group.isRaidGroup();
bool isRaid = !_isPvP && CliDB.MapStorage.LookupByKey(_killer.GetMapId()).IsRaid() && _group.IsRaidGroup();
_groupRate = Formulas.XPInGroupRate(_count, isRaid);
}
// 3.1.3. Reward each group member (even dead or corpse) within reward distance.
for (GroupReference refe = _group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = _group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player member = refe.GetSource();
if (member)
+1 -1
View File
@@ -58,7 +58,7 @@ namespace Game.Entities
Group group = GetGroup();
if (group)
{
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player player = refe.GetSource();
if (!player)
+1 -1
View File
@@ -3431,7 +3431,7 @@ namespace Game.Entities
// check if stats should only be saved on logout
// save stats can be out of transaction
if (GetSession().isLogingOut() || !WorldConfig.GetBoolValue(WorldCfg.StatsSaveOnlyOnLogout))
if (GetSession().IsLogingOut() || !WorldConfig.GetBoolValue(WorldCfg.StatsSaveOnlyOnLogout))
_SaveStats(trans);
DB.Characters.CommitTransaction(trans);
+22 -22
View File
@@ -32,7 +32,7 @@ namespace Game.Entities
List<Player> nearMembers = new List<Player>();
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player Target = refe.GetSource();
@@ -55,7 +55,7 @@ namespace Game.Entities
if (!grp)
return PartyResult.NotInGroup;
if (grp.isLFGGroup())
if (grp.IsLFGGroup())
{
ObjectGuid gguid = grp.GetGUID();
if (Global.LFGMgr.GetKicksLeft(gguid) == 0)
@@ -71,11 +71,11 @@ namespace Game.Entities
if (state == LfgState.FinishedDungeon)
return PartyResult.PartyLfgBootDungeonComplete;
if (grp.isRollLootActive())
if (grp.IsRollLootActive())
return PartyResult.PartyLfgBootLootRolls;
// @todo Should also be sent when anyone has recently left combat, with an aprox ~5 seconds timer.
for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.Next())
if (refe.GetSource() && refe.GetSource().IsInMap(this) && refe.GetSource().IsInCombat())
return PartyResult.PartyLfgBootInCombat;
@@ -106,10 +106,10 @@ namespace Game.Entities
bool InRandomLfgDungeon()
{
if (Global.LFGMgr.selectedRandomLfgDungeon(GetGUID()))
if (Global.LFGMgr.SelectedRandomLfgDungeon(GetGUID()))
{
Map map = GetMap();
return Global.LFGMgr.inLfgDungeonMap(GetGUID(), map.GetId(), map.GetDifficultyID());
return Global.LFGMgr.InLfgDungeonMap(GetGUID(), map.GetId(), map.GetDifficultyID());
}
return false;
@@ -120,20 +120,20 @@ namespace Game.Entities
//we must move references from m_group to m_originalGroup
SetOriginalGroup(GetGroup(), GetSubGroup());
m_group.unlink();
m_group.link(group, this);
m_group.setSubGroup(subgroup);
m_group.Unlink();
m_group.Link(group, this);
m_group.SetSubGroup(subgroup);
}
public void RemoveFromBattlegroundOrBattlefieldRaid()
{
//remove existing reference
m_group.unlink();
m_group.Unlink();
Group group = GetOriginalGroup();
if (group)
{
m_group.link(group, this);
m_group.setSubGroup(GetOriginalSubGroup());
m_group.Link(group, this);
m_group.SetSubGroup(GetOriginalSubGroup());
}
SetOriginalGroup(null);
}
@@ -141,22 +141,22 @@ namespace Game.Entities
public void SetOriginalGroup(Group group, byte subgroup = 0)
{
if (!group)
m_originalGroup.unlink();
m_originalGroup.Unlink();
else
{
m_originalGroup.link(group, this);
m_originalGroup.setSubGroup(subgroup);
m_originalGroup.Link(group, this);
m_originalGroup.SetSubGroup(subgroup);
}
}
public void SetGroup(Group group, byte subgroup = 0)
{
if (!group)
m_group.unlink();
m_group.Unlink();
else
{
m_group.link(group, this);
m_group.setSubGroup(subgroup);
m_group.Link(group, this);
m_group.SetSubGroup(subgroup);
}
UpdateObjectVisibility(false);
@@ -206,16 +206,16 @@ namespace Game.Entities
public Group GetGroupInvite() { return m_groupInvite; }
public void SetGroupInvite(Group group) { m_groupInvite = group; }
public Group GetGroup() { return m_group.getTarget(); }
public Group GetGroup() { return m_group.GetTarget(); }
public GroupReference GetGroupRef() { return m_group; }
public byte GetSubGroup() { return m_group.getSubGroup(); }
public byte GetSubGroup() { return m_group.GetSubGroup(); }
public GroupUpdateFlags GetGroupUpdateFlag() { return m_groupUpdateMask; }
public void SetGroupUpdateFlag(GroupUpdateFlags flag) { m_groupUpdateMask |= flag; }
public void RemoveGroupUpdateFlag(GroupUpdateFlags flag) { m_groupUpdateMask &= ~flag; }
public Group GetOriginalGroup() { return m_originalGroup.getTarget(); }
public Group GetOriginalGroup() { return m_originalGroup.GetTarget(); }
public GroupReference GetOriginalGroupRef() { return m_originalGroup; }
public byte GetOriginalSubGroup() { return m_originalGroup.getSubGroup(); }
public byte GetOriginalSubGroup() { return m_originalGroup.GetSubGroup(); }
public void SetPassOnGroupLoot(bool bPassOnGroupLoot) { m_bPassOnGroupLoot = bPassOnGroupLoot; }
public bool GetPassOnGroupLoot() { return m_bPassOnGroupLoot; }
+12 -12
View File
@@ -3309,12 +3309,12 @@ namespace Game.Entities
public InventoryResult CanRollForItemInLFG(ItemTemplate proto, WorldObject lootedObject)
{
if (!GetGroup() || !GetGroup().isLFGGroup())
if (!GetGroup() || !GetGroup().IsLFGGroup())
return InventoryResult.Ok; // not in LFG group
// check if looted object is inside the lfg dungeon
Map map = lootedObject.GetMap();
if (!Global.LFGMgr.inLfgDungeonMap(GetGroup().GetGUID(), map.GetId(), map.GetDifficultyID()))
if (!Global.LFGMgr.InLfgDungeonMap(GetGroup().GetGUID(), map.GetId(), map.GetDifficultyID()))
return InventoryResult.Ok;
if (proto == null)
@@ -5138,7 +5138,7 @@ namespace Game.Entities
return InventoryResult.NotInCombat;
Battleground bg = GetBattleground();
if (bg)
if (bg.isArena() && bg.GetStatus() == BattlegroundStatus.InProgress)
if (bg.IsArena() && bg.GetStatus() == BattlegroundStatus.InProgress)
return InventoryResult.NotDuringArenaMatch;
}
@@ -5371,7 +5371,7 @@ namespace Game.Entities
return InventoryResult.NotInCombat;
Battleground bg = GetBattleground();
if (bg)
if (bg.isArena() && bg.GetStatus() == BattlegroundStatus.InProgress)
if (bg.IsArena() && bg.GetStatus() == BattlegroundStatus.InProgress)
return InventoryResult.NotDuringArenaMatch;
}
@@ -6235,7 +6235,7 @@ namespace Game.Entities
// loot was generated and respawntime has passed since then, allow to recreate loot
// to avoid bugs, this rule covers spawned gameobjects only
if (go.IsSpawnedByDefault() && go.GetLootState() == LootState.Activated && !go.loot.isLooted() && go.GetLootGenerationTime() + go.GetRespawnDelay() < Time.UnixTime)
if (go.IsSpawnedByDefault() && go.GetLootState() == LootState.Activated && !go.loot.IsLooted() && go.GetLootGenerationTime() + go.GetRespawnDelay() < Time.UnixTime)
go.SetLootState(LootState.Ready);
if (go.GetLootState() == LootState.Ready)
@@ -6253,7 +6253,7 @@ namespace Game.Entities
if (lootid != 0)
{
loot.clear();
loot.Clear();
Group group = GetGroup();
bool groupRules = (group && go.GetGoInfo().type == GameObjectTypes.Chest && go.GetGoInfo().Chest.usegrouplootrules != 0);
@@ -6274,7 +6274,7 @@ namespace Game.Entities
{
GameObjectTemplateAddon addon = go.GetTemplateAddon();
if (addon != null)
loot.generateMoneyLoot(addon.mingold, addon.maxgold);
loot.GenerateMoneyLoot(addon.mingold, addon.maxgold);
}
if (loot_type == LootType.Fishing)
@@ -6346,7 +6346,7 @@ namespace Game.Entities
if (!item.m_lootGenerated && !item.ItemContainerLoadLootFromDB())
{
item.m_lootGenerated = true;
loot.clear();
loot.Clear();
switch (loot_type)
{
@@ -6360,7 +6360,7 @@ namespace Game.Entities
loot.FillLoot(item.GetEntry(), LootStorage.Milling, this, true);
break;
default:
loot.generateMoneyLoot(item.GetTemplate().MinMoneyLoot, item.GetTemplate().MaxMoneyLoot);
loot.GenerateMoneyLoot(item.GetTemplate().MinMoneyLoot, item.GetTemplate().MaxMoneyLoot);
loot.FillLoot(item.GetEntry(), LootStorage.Items, this, true, loot.gold != 0);
// Force save the loot and money items that were just rolled
@@ -6387,7 +6387,7 @@ namespace Game.Entities
if (loot.loot_type == LootType.None)
{
uint pLevel = bones.loot.gold;
bones.loot.clear();
bones.loot.Clear();
// For AV Achievement
Battleground bg = GetBattleground();
@@ -6435,7 +6435,7 @@ namespace Game.Entities
if (creature.CanGeneratePickPocketLoot())
{
creature.StartPickPocketRefillTimer();
loot.clear();
loot.Clear();
uint lootid = creature.GetCreatureTemplate().PickPocketId;
if (lootid != 0)
@@ -6500,7 +6500,7 @@ namespace Game.Entities
}
else if (loot_type == LootType.Skinning)
{
loot.clear();
loot.Clear();
loot.FillLoot(creature.GetCreatureTemplate().SkinLootId, LootStorage.Skinning, this, true);
permission = PermissionTypes.Owner;
+2 -2
View File
@@ -537,7 +537,7 @@ namespace Game.Entities
// raid instances require the player to be in a raid group to be valid
if (map.IsRaid() && !WorldConfig.GetBoolValue(WorldCfg.InstanceIgnoreRaid) && (map.GetEntry().Expansion() >= (Expansion)WorldConfig.GetIntValue(WorldCfg.Expansion)))
if (!GetGroup() || !GetGroup().isRaidGroup())
if (!GetGroup() || !GetGroup().IsRaidGroup())
return false;
Group group = GetGroup();
@@ -715,7 +715,7 @@ namespace Game.Entities
public override void UpdateUnderwaterState(Map m, float x, float y, float z)
{
LiquidData liquid_status;
ZLiquidStatus res = m.getLiquidStatus(GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out liquid_status);
ZLiquidStatus res = m.GetLiquidStatus(GetPhaseShift(), x, y, z, MapConst.MapAllLiquidTypes, out liquid_status);
if (res == 0)
{
m_MirrorTimerFlags &= ~(PlayerUnderwaterState.InWater | PlayerUnderwaterState.InLava | PlayerUnderwaterState.InSlime | PlayerUnderwaterState.InDarkWater);
+4 -4
View File
@@ -85,7 +85,7 @@ namespace Game.Entities
UpdateHonorFields();
// do not reward honor in arenas, but return true to enable onkill spellproc
if (InBattleground() && GetBattleground() && GetBattleground().isArena())
if (InBattleground() && GetBattleground() && GetBattleground().IsArena())
return true;
// Promote to float for calculations
@@ -132,7 +132,7 @@ namespace Game.Entities
else
victim_guid.Clear(); // Don't show HK: <rank> message, only log.
honor_f = (float)Math.Ceiling(Formulas.hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
honor_f = (float)Math.Ceiling(Formulas.HKHonorAtLevelF(k_level) * (v_level - k_grey) / (k_level - k_grey));
// count the number of playerkills in one day
ApplyModUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.TodayHonorableKills), (ushort)1, true);
@@ -729,7 +729,7 @@ namespace Game.Entities
bg.RemovePlayerAtLeave(GetGUID(), teleportToEntryPoint, true);
// call after remove to be sure that player resurrected for correct cast
if (bg.isBattleground() && !IsGameMaster() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundCastDeserter))
if (bg.IsBattleground() && !IsGameMaster() && WorldConfig.GetBoolValue(WorldCfg.BattlegroundCastDeserter))
{
if (bg.GetStatus() == BattlegroundStatus.InProgress || bg.GetStatus() == BattlegroundStatus.WaitJoin)
{
@@ -752,7 +752,7 @@ namespace Game.Entities
if (HasAura(26013))
return false;
if (bg.isArena() && !GetSession().HasPermission(RBACPermissions.JoinArenas))
if (bg.IsArena() && !GetSession().HasPermission(RBACPermissions.JoinArenas))
return false;
if (bg.IsRandom() && !GetSession().HasPermission(RBACPermissions.JoinRandomBg))
+6 -6
View File
@@ -580,7 +580,7 @@ namespace Game.Entities
{
case TypeId.Unit:
Global.ScriptMgr.OnQuestAccept(this, (questGiver.ToCreature()), quest);
questGiver.ToCreature().GetAI().sQuestAccept(this, quest);
questGiver.ToCreature().GetAI().QuestAccept(this, quest);
break;
case TypeId.Item:
case TypeId.Container:
@@ -2077,7 +2077,7 @@ namespace Game.Entities
var group = GetGroup();
if (group)
{
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player player = refe.GetSource();
@@ -2216,7 +2216,7 @@ namespace Game.Entities
// just if !ingroup || !noraidgroup || raidgroup
QuestStatusData q_status = m_QuestStatus[questid];
if (q_status.Status == QuestStatus.Incomplete && (GetGroup() == null || !GetGroup().isRaidGroup() || qInfo.IsAllowedInRaid(GetMap().GetDifficultyID())))
if (q_status.Status == QuestStatus.Incomplete && (GetGroup() == null || !GetGroup().IsRaidGroup() || qInfo.IsAllowedInRaid(GetMap().GetDifficultyID())))
{
if (qInfo.HasSpecialFlag(QuestSpecialFlags.Kill))// && !qInfo.HasSpecialFlag(QuestSpecialFlags.Cast))
{
@@ -2263,7 +2263,7 @@ namespace Game.Entities
// just if !ingroup || !noraidgroup || raidgroup
QuestStatusData q_status = m_QuestStatus[questid];
if (q_status.Status == QuestStatus.Incomplete && (GetGroup() == null || !GetGroup().isRaidGroup() || qInfo.IsAllowedInRaid(GetMap().GetDifficultyID())))
if (q_status.Status == QuestStatus.Incomplete && (GetGroup() == null || !GetGroup().IsRaidGroup() || qInfo.IsAllowedInRaid(GetMap().GetDifficultyID())))
{
foreach (QuestObjective obj in qInfo.Objectives)
{
@@ -2550,7 +2550,7 @@ namespace Game.Entities
continue;
// hide quest if player is in raid-group and quest is no raid quest
if (GetGroup() != null && GetGroup().isRaidGroup() && !qInfo.IsAllowedInRaid(GetMap().GetDifficultyID()))
if (GetGroup() != null && GetGroup().IsRaidGroup() && !qInfo.IsAllowedInRaid(GetMap().GetDifficultyID()))
if (!InBattleground()) //there are two ways.. we can make every bg-quest a raidquest, or add this code here.. i don't know if this can be exploited by other quests, but i think all other quests depend on a specific area.. but keep this in mind, if something strange happens later
continue;
@@ -2943,7 +2943,7 @@ namespace Game.Entities
if (qInfo == null)
continue;
if (GetGroup() != null && GetGroup().isRaidGroup() && !qInfo.IsAllowedInRaid(GetMap().GetDifficultyID()))
if (GetGroup() != null && GetGroup().IsRaidGroup() && !qInfo.IsAllowedInRaid(GetMap().GetDifficultyID()))
continue;
foreach (QuestObjective obj in qInfo.Objectives)
+4 -4
View File
@@ -1529,7 +1529,7 @@ namespace Game.Entities
spell.m_fromClient = true;
spell.m_CastItem = item;
spell.SetSpellValue(SpellValueMod.BasePoint0, (int)learning_spell_id);
spell.prepare(targets);
spell.Prepare(targets);
return;
}
}
@@ -1565,7 +1565,7 @@ namespace Game.Entities
spell.m_CastItem = item;
spell.m_misc.Data0 = misc[0];
spell.m_misc.Data1 = misc[1];
spell.prepare(targets);
spell.Prepare(targets);
return;
}
@@ -1599,7 +1599,7 @@ namespace Game.Entities
spell.m_CastItem = item;
spell.m_misc.Data0 = misc[0];
spell.m_misc.Data1 = misc[1];
spell.prepare(targets);
spell.Prepare(targets);
return;
}
}
@@ -1697,7 +1697,7 @@ namespace Game.Entities
{
Spell spell = GetCurrentSpell(i);
if (spell != null)
if (spell.getState() != SpellState.Delayed && !HasItemFitToSpellRequirements(spell.m_spellInfo, pItem))
if (spell.GetState() != SpellState.Delayed && !HasItemFitToSpellRequirements(spell.m_spellInfo, pItem))
InterruptSpell(i);
}
}
+15 -15
View File
@@ -731,7 +731,7 @@ namespace Game.Entities
{
m_hostileReferenceCheckTimer = 15 * Time.InMilliseconds;
if (!GetMap().IsDungeon())
GetHostileRefManager().deleteReferencesOutOfRange(GetVisibilityRange());
GetHostileRefManager().DeleteReferencesOutOfRange(GetVisibilityRange());
}
else
m_hostileReferenceCheckTimer -= diff;
@@ -1958,7 +1958,7 @@ namespace Game.Entities
// remove auras that need water/land
RemoveAurasWithInterruptFlags((apply ? SpellAuraInterruptFlags.NotAbovewater : SpellAuraInterruptFlags.NotUnderwater));
GetHostileRefManager().updateThreatTables();
GetHostileRefManager().UpdateThreatTables();
}
public void ValidateMovementInfo(MovementInfo mi)
{
@@ -2200,13 +2200,13 @@ namespace Game.Entities
if (pet != null)
{
pet.SetFaction(35);
pet.GetHostileRefManager().setOnlineOfflineState(false);
pet.GetHostileRefManager().SetOnlineOfflineState(false);
}
RemovePvpFlag(UnitPVPStateFlags.FFAPvp);
ResetContestedPvP();
GetHostileRefManager().setOnlineOfflineState(false);
GetHostileRefManager().SetOnlineOfflineState(false);
CombatStopWithPets();
PhasingHandler.SetAlwaysVisible(GetPhaseShift(), true);
@@ -2225,7 +2225,7 @@ namespace Game.Entities
if (pet != null)
{
pet.SetFaction(GetFaction());
pet.GetHostileRefManager().setOnlineOfflineState(true);
pet.GetHostileRefManager().SetOnlineOfflineState(true);
}
// restore FFA PvP Server state
@@ -2235,7 +2235,7 @@ namespace Game.Entities
// restore FFA PvP area state, remove not allowed for GM mounts
UpdateArea(m_areaUpdateId);
GetHostileRefManager().setOnlineOfflineState(true);
GetHostileRefManager().SetOnlineOfflineState(true);
m_serverSideVisibilityDetect.SetValue(ServerSideVisibilityType.GM, AccountTypes.Player);
}
@@ -3652,9 +3652,9 @@ namespace Game.Entities
return false;
Loot loot = creature.loot;
if (loot.isLooted()) // nothing to loot or everything looted.
if (loot.IsLooted()) // nothing to loot or everything looted.
return false;
if (!loot.hasItemForAll() && !loot.hasItemFor(this)) // no loot in creature for this player
if (!loot.HasItemForAll() && !loot.HasItemFor(this)) // no loot in creature for this player
return false;
if (loot.loot_type == LootType.Skinning)
@@ -3680,10 +3680,10 @@ namespace Game.Entities
if (loot.roundRobinPlayer.IsEmpty() || loot.roundRobinPlayer == GetGUID())
return true;
if (loot.hasOverThresholdItem())
if (loot.HasOverThresholdItem())
return true;
return loot.hasItemFor(this);
return loot.HasItemFor(this);
}
return false;
@@ -4241,7 +4241,7 @@ namespace Game.Entities
SetHealth(1);
SetWaterWalking(true);
if (!GetSession().isLogingOut() && !HasUnitState(UnitState.Stunned))
if (!GetSession().IsLogingOut() && !HasUnitState(UnitState.Stunned))
SetRooted(false);
// BG - remove insignia related
@@ -4966,7 +4966,7 @@ namespace Game.Entities
public bool InArena()
{
Battleground bg = GetBattleground();
if (!bg || !bg.isArena())
if (!bg || !bg.IsArena())
return false;
return true;
@@ -6732,7 +6732,7 @@ namespace Game.Entities
}
// not let cheating with start flight in time of logout process || while in combat || has type state: stunned || has type state: root
if (GetSession().isLogingOut() || IsInCombat() || HasUnitState(UnitState.Stunned) || HasUnitState(UnitState.Root))
if (GetSession().IsLogingOut() || IsInCombat() || HasUnitState(UnitState.Stunned) || HasUnitState(UnitState.Root))
{
GetSession().SendActivateTaxiReply(ActivateTaxiReply.PlayerBusy);
return false;
@@ -6924,7 +6924,7 @@ namespace Game.Entities
m_taxi.ClearTaxiDestinations(); // not destinations, clear source node
Dismount();
RemoveUnitFlag(UnitFlags.RemoveClientControl | UnitFlags.TaxiFlight);
GetHostileRefManager().setOnlineOfflineState(true);
GetHostileRefManager().SetOnlineOfflineState(true);
}
public void ContinueTaxiFlight()
@@ -6987,7 +6987,7 @@ namespace Game.Entities
Group group = GetGroup();
if (group)
{
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
{
Player player = refe.GetSource();
if (!player)