Skip to content

Commit 15d5a27

Browse files
committed
clean up codestyle
1 parent 005bb8a commit 15d5a27

File tree

1 file changed

+6
-57
lines changed

1 file changed

+6
-57
lines changed

src/mod_zone_difficulty_handler.cpp

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -695,34 +695,22 @@ bool ZoneDifficulty::VectorContainsUint32(std::vector<uint32> vec, uint32 elemen
695695
bool ZoneDifficulty::ShouldNerfInDuels(Unit* target)
696696
{
697697
if (target->GetAreaId() != DUEL_AREA)
698-
{
699698
return false;
700-
}
701699

702700
if (target->ToTempSummon() && target->ToTempSummon()->GetSummoner())
703-
{
704701
target = target->ToTempSummon()->GetSummoner()->ToUnit();
705-
}
706702

707703
if (!target->GetAffectingPlayer())
708-
{
709704
return false;
710-
}
711705

712706
if (!target->GetAffectingPlayer()->duel)
713-
{
714707
return false;
715-
}
716708

717709
if (target->GetAffectingPlayer()->duel->State != DUEL_STATE_IN_PROGRESS)
718-
{
719710
return false;
720-
}
721711

722712
if (!target->GetAffectingPlayer()->duel->Opponent)
723-
{
724713
return false;
725-
}
726714

727715
return true;
728716
}
@@ -750,7 +738,6 @@ int32 ZoneDifficulty::GetLowestMatchingPhase(uint32 mapId, uint32 phaseMask)
750738
return 0;
751739
}
752740

753-
// Check all $key in [mapId][$key] if they match the target's visible phases
754741
for (auto const& [key, value] : sZoneDifficulty->NerfInfo[mapId])
755742
{
756743
if (key & phaseMask)
@@ -767,42 +754,36 @@ int32 ZoneDifficulty::GetLowestMatchingPhase(uint32 mapId, uint32 phaseMask)
767754
* zone_difficulty_instance_saves is used to store the data.
768755
*
769756
* @param InstanceID INT NOT NULL DEFAULT 0,
770-
* @param MythicmodeOn TINYINT NOT NULL DEFAULT 0,
771757
*/
772758
void ZoneDifficulty::SaveMythicmodeInstanceData(uint32 instanceId)
773759
{
774760
if (sZoneDifficulty->MythicmodeInstanceData.find(instanceId) == sZoneDifficulty->MythicmodeInstanceData.end())
775761
{
776-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: ZoneDifficulty::SaveMythicmodeInstanceData: InstanceId {} not found in MythicmodeInstanceData.", instanceId);
777762
return;
778763
}
779-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: ZoneDifficulty::SaveMythicmodeInstanceData: Saving instanceId {} with MythicmodeOn {}", instanceId, sZoneDifficulty->MythicmodeInstanceData[instanceId]);
780764
CharacterDatabase.Execute("REPLACE INTO zone_difficulty_instance_saves (InstanceID, MythicmodeOn) VALUES ({}, {})", instanceId, sZoneDifficulty->MythicmodeInstanceData[instanceId]);
781765
}
782766

783767
void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
784768
{
785-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: MythicmodeEvent for entry {} with key {}", entry, key);
786769
if (unit && unit->IsAlive())
787770
{
788771
if (!unit->IsInCombat())
789772
{
790773
unit->m_Events.CancelEventGroup(EVENT_GROUP);
791774
return;
792775
}
793-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: MythicmodeEvent IsInCombat for entry {} with key {}", entry, key);
776+
794777
// Try again in 1s if the unit is currently casting
795778
if (unit->HasUnitState(UNIT_STATE_CASTING))
796779
{
797-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: MythicmodeEvent Re-schedule AI event in 1s because unit is casting for entry {} with key {}", entry, key);
798780
unit->m_Events.AddEventAtOffset([unit, entry, key]()
799781
{
800782
sZoneDifficulty->MythicmodeEvent(unit, entry, key);
801783
}, 1s, EVENT_GROUP);
802784
return;
803785
}
804786

805-
//Re-schedule the event
806787
if (sZoneDifficulty->MythicmodeAI[entry][key].Repetitions == 0)
807788
{
808789
unit->m_Events.AddEventAtOffset([unit, entry, key]()
@@ -816,7 +797,6 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
816797
bool has_bp1 = mythicAI.Spellbp1;
817798
bool has_bp2 = mythicAI.Spellbp2;
818799

819-
//Multiple targets
820800
if (mythicAI.Target == TARGET_PLAYER_DISTANCE)
821801
{
822802
auto const& threatlist = unit->GetThreatMgr().GetThreatList();
@@ -825,24 +805,18 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
825805
{
826806
Unit* target = (*itr)->getTarget();
827807
if (!unit->IsWithinDist(target, mythicAI.TargetArg))
828-
{
829808
continue;
830-
}
831809

832810
std::string targetName = target ? target->GetName() : "NoTarget";
833811
if (!has_bp0 && !has_bp1 && !has_bp2)
834-
{
835812
unit->CastSpell(target, mythicAI.Spell, mythicAI.TriggeredCast);
836-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Creature casting MythicmodeAI spell: {} at target {}", mythicAI.Spell, targetName);
837-
}
838813
else
839814
{
840815
unit->CastCustomSpell(target, mythicAI.Spell,
841816
has_bp0 ? &mythicAI.Spellbp0 : NULL,
842817
has_bp1 ? &mythicAI.Spellbp1 : NULL,
843818
has_bp2 ? &mythicAI.Spellbp2 : NULL,
844819
mythicAI.TriggeredCast);
845-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Creature casting MythicmodeAI spell: {} at target {} with custom values.", mythicAI.Spell, targetName);
846820
}
847821
}
848822
return;
@@ -851,13 +825,9 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
851825
// Select target
852826
Unit* target = nullptr;
853827
if (mythicAI.Target == TARGET_SELF)
854-
{
855828
target = unit;
856-
}
857829
else if (mythicAI.Target == TARGET_VICTIM)
858-
{
859830
target = unit->GetVictim();
860-
}
861831
else
862832
{
863833
switch (mythicAI.Target)
@@ -866,46 +836,36 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
866836
{
867837
float range = 200.0f;
868838
if (mythicAI.TargetArg > 0)
869-
{
870839
range = mythicAI.TargetArg;
871-
}
840+
872841
target = unit->GetAI()->SelectTarget(SelectTargetMethod::MaxThreat, mythicAI.TargetArg2, range, true);
873842

874843
if (!target)
875-
{
876-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Fall-back to GetVictim()");
877844
target = unit->GetVictim();
878-
}
879-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Selecting target type TARGET_HOSTILE_AGGRO_FROM_TOP with range TargetArg {} and position on threat-list TargetArg2 {}.", mythicAI.TargetArg, range);
845+
880846
break;
881847
}
882848
case TARGET_HOSTILE_AGGRO_FROM_BOTTOM:
883849
{
884850
float range = 200.0f;
885851
if (mythicAI.TargetArg2 > 0)
886-
{
887852
range = mythicAI.TargetArg2;
888-
}
853+
889854
target = unit->GetAI()->SelectTarget(SelectTargetMethod::MinThreat, mythicAI.TargetArg, range, true);
890855

891856
if (!target)
892-
{
893-
//LOG_INFO("module", "Fall-back to GetVictim()");
894857
target = unit->GetVictim();
895-
}
896-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Selecting target type TARGET_HOSTILE_AGGRO_FROM_TOP with range TargetArg {} and position on threat-list TargetArg2 {}.", mythicAI.TargetArg, range);
858+
897859
break;
898860
}
899861
case TARGET_HOSTILE_RANDOM:
900862
{
901863
target = unit->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, mythicAI.TargetArg, true);
902-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Selecting target type TARGET_HOSTILE_RANDOM with max range {}.", mythicAI.TargetArg);
903864
break;
904-
}
865+
}
905866
case TARGET_HOSTILE_RANDOM_NOT_TOP:
906867
{
907868
target = unit->GetAI()->SelectTarget(SelectTargetMethod::Random, 0, mythicAI.TargetArg, true, false);
908-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Selecting target type TARGET_HOSTILE_RANDOM_NOT_TOP with max range {}.", mythicAI.TargetArg);
909869
break;
910870
}
911871
default:
@@ -921,16 +881,12 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
921881
if (mythicAI.TargetArg > 0)
922882
{
923883
if (unit->IsInRange(victim, 0, mythicAI.TargetArg, true))
924-
{
925884
target = victim;
926-
}
927885
}
928886
else if (mythicAI.TargetArg < 0)
929887
{
930888
if (unit->IsInRange(victim, mythicAI.TargetArg, 0, true))
931-
{
932889
target = victim;
933-
}
934890
}
935891

936892
}
@@ -942,7 +898,6 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
942898
if (!has_bp0 && !has_bp1 && !has_bp2)
943899
{
944900
unit->CastSpell(target, mythicAI.Spell, mythicAI.TriggeredCast);
945-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Creature casting MythicmodeAI spell: {} at target {}", mythicAI.Spell, targetName);
946901
}
947902
else
948903
{
@@ -951,7 +906,6 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
951906
has_bp1 ? &mythicAI.Spellbp1 : NULL,
952907
has_bp2 ? &mythicAI.Spellbp2 : NULL,
953908
mythicAI.TriggeredCast);
954-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Creature casting MythicmodeAI spell: {} at target {} with custom values.", mythicAI.Spell, targetName);
955909
}
956910
}
957911
else
@@ -963,7 +917,6 @@ void ZoneDifficulty::MythicmodeEvent(Unit* unit, uint32 entry, uint32 key)
963917

964918
bool ZoneDifficulty::HasCompletedFullTier(uint32 category, uint32 playerGuid)
965919
{
966-
//LOG_INFO("module", "MOD-ZONE-DIFFCULTY: Executing HasCompletedFullTier for category {} playerGUID {}.", category, playerGuid);
967920
std::vector<uint32> MapList;
968921
switch (category)
969922
{
@@ -988,7 +941,6 @@ bool ZoneDifficulty::HasCompletedFullTier(uint32 category, uint32 playerGuid)
988941

989942
for (uint32 mapId : MapList)
990943
{
991-
//LOG_INFO("module", "MOD-ZONE-DIFFCULTY: Checking HasCompletedFullTier for mapId {}.", mapId);
992944
if (sZoneDifficulty->EncounterCounter.find(mapId) == sZoneDifficulty->EncounterCounter.end())
993945
{
994946
LOG_ERROR("module", "MOD-ZONE-DIFFICULTY: Map without data requested in ZoneDifficulty::HasCompletedFullTier {}", mapId);
@@ -1005,7 +957,6 @@ bool ZoneDifficulty::HasCompletedFullTier(uint32 category, uint32 playerGuid)
1005957

1006958
void ZoneDifficulty::RewardItem(Player* player, uint8 category, uint8 itemType, uint8 counter, Creature* creature, uint32 itemEntry)
1007959
{
1008-
// Check (again) if the player has enough score in the respective category.
1009960
uint32 availableScore = player->GetPlayerSetting(ModZoneDifficultyString + "score", category).value;
1010961

1011962
auto reward = sZoneDifficulty->Rewards[category][itemType][counter];
@@ -1045,7 +996,6 @@ void ZoneDifficulty::RewardItem(Player* player, uint8 category, uint8 itemType,
1045996
return;
1046997
}
1047998

1048-
// Check if the player has the neccesary achievement
1049999
if (reward.Achievement)
10501000
{
10511001
if (!player->HasAchieved(reward.Achievement))
@@ -1059,7 +1009,6 @@ void ZoneDifficulty::RewardItem(Player* player, uint8 category, uint8 itemType,
10591009
}
10601010
}
10611011

1062-
//LOG_INFO("module", "MOD-ZONE-DIFFICULTY: Sending item with category {}, itemType {}, counter {}", category, itemType, counter);
10631012
sZoneDifficulty->DeductMythicmodeScore(player, category, reward.Price);
10641013
sZoneDifficulty->SendItem(player, reward);
10651014

0 commit comments

Comments
 (0)