Core/Misc: fix some /W4 warnings and some reported by GCC 6.3

This commit is contained in:
ariel-
2018-01-22 23:55:33 -03:00
parent 7c9722a4ae
commit c099174ff7
21 changed files with 159 additions and 172 deletions

View File

@@ -416,33 +416,29 @@ public:
for (auto const& itemTemplatePair : its)
{
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
if (localeIndex >= 0)
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplatePair.first))
{
uint8 ulocaleIndex = uint8(localeIndex);
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplatePair.first))
if (il->Name.size() > localeIndex && !il->Name[localeIndex].empty())
{
if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
std::string const& name = il->Name[localeIndex];
if (Utf8FitTo(name, wNamePart))
{
std::string const& name = il->Name[ulocaleIndex];
if (Utf8FitTo(name, wNamePart))
if (maxResults && count++ == maxResults)
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplatePair.first, itemTemplatePair.first, name.c_str());
else
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplatePair.first, name.c_str());
if (!found)
found = true;
continue;
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplatePair.first, itemTemplatePair.first, name.c_str());
else
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplatePair.first, name.c_str());
if (!found)
found = true;
continue;
}
}
}
@@ -647,53 +643,49 @@ public:
for (auto const& questTemplatePair : questTemplates)
{
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
if (localeIndex >= 0)
if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(questTemplatePair.first))
{
uint8 ulocaleIndex = uint8(localeIndex);
if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(questTemplatePair.first))
if (questLocale->Title.size() > localeIndex && !questLocale->Title[localeIndex].empty())
{
if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty())
std::string const& title = questLocale->Title[localeIndex];
if (Utf8FitTo(title, wNamePart))
{
std::string const& title = questLocale->Title[ulocaleIndex];
if (Utf8FitTo(title, wNamePart))
if (maxResults && count++ == maxResults)
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
char const* statusStr = "";
if (target)
{
switch (target->GetQuestStatus(questTemplatePair.first))
{
case QUEST_STATUS_COMPLETE:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
break;
case QUEST_STATUS_INCOMPLETE:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
break;
case QUEST_STATUS_REWARDED:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
break;
default:
break;
}
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, questTemplatePair.first, questTemplatePair.first, questTemplatePair.second.GetQuestLevel(), title.c_str(), statusStr);
else
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, questTemplatePair.first, title.c_str(), statusStr);
if (!found)
found = true;
continue;
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
char const* statusStr = "";
if (target)
{
switch (target->GetQuestStatus(questTemplatePair.first))
{
case QUEST_STATUS_COMPLETE:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_COMPLETE);
break;
case QUEST_STATUS_INCOMPLETE:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_ACTIVE);
break;
case QUEST_STATUS_REWARDED:
statusStr = handler->GetTrinityString(LANG_COMMAND_QUEST_REWARDED);
break;
default:
break;
}
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, questTemplatePair.first, questTemplatePair.first, questTemplatePair.second.GetQuestLevel(), title.c_str(), statusStr);
else
handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, questTemplatePair.first, title.c_str(), statusStr);
if (!found)
found = true;
continue;
}
}
}

View File

@@ -567,7 +567,7 @@ class spell_auriaya_agro_creator : public SpellScript
}
};
// 61906 - Random Aggro Periodic (5 sec)
// 61906 - Random Aggro Periodic (5 sec)
class spell_auriaya_random_agro_periodic : public AuraScript
{
PrepareAuraScript(spell_auriaya_random_agro_periodic);
@@ -583,17 +583,16 @@ class spell_auriaya_random_agro_periodic : public AuraScript
if (!owner || !owner->IsAIEnabled || owner->HasReactState(REACT_PASSIVE))
return;
if (Unit* target = owner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, CatsTargetSelector(owner, 15.0f, 25.0f)))
{
owner->GetThreatManager().AddThreat(target, 3000000.0f, nullptr, true);
owner->CastSpell(target, SPELL_FERAL_POUNCE, true);
owner->AI()->AttackStart(target);
}
else if (Unit* target = owner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0))
{
owner->GetThreatManager().AddThreat(target, 3000000.0f);
owner->AI()->AttackStart(target);
}
Unit* target = owner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, CatsTargetSelector(owner, 15.0f, 25.0f));
if (!target)
target = owner->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0);
if (!target)
return;
owner->GetThreatManager().AddThreat(target, 3000000.0f, nullptr, true);
owner->CastSpell(target, SPELL_FERAL_POUNCE, true);
owner->AI()->AttackStart(target);
}
void Register() override

View File

@@ -1736,7 +1736,7 @@ class spell_dk_pestilence : public SpellScriptLoader
float donePct = aurOld->GetDonePct();
float critChance = aurOld->GetCritChance();
if (AuraEffect* aurEffOld = aurOld->GetEffect(EFFECT_0))
if (aurOld->GetEffect(EFFECT_0))
{
caster->CastSpell(hitUnit, SPELL_DK_BLOOD_PLAGUE, true); // Spread the disease to hitUnit.
@@ -1754,7 +1754,7 @@ class spell_dk_pestilence : public SpellScriptLoader
{
float donePct = aurOld->GetDonePct();
if (AuraEffect* aurEffOld = aurOld->GetEffect(EFFECT_0))
if (aurOld->GetEffect(EFFECT_0))
{
caster->CastSpell(hitUnit, SPELL_DK_FROST_FEVER, true); // Spread the disease to hitUnit.

View File

@@ -830,7 +830,6 @@ class spell_warl_life_tap : public SpellScriptLoader
if (AuraEffect const* aurEff = caster->GetDummyAuraEffect(SPELLFAMILY_WARLOCK, WARLOCK_ICON_ID_IMPROVED_LIFE_TAP, 0))
AddPct(mana, aurEff->GetAmount());
// @todo castspell refactor note: this is not triggered - intended?
CastSpellExtraArgs args;
args.AddSpellBP0(mana);
caster->CastSpell(target, SPELL_WARLOCK_LIFE_TAP_ENERGIZE, args);
@@ -843,9 +842,9 @@ class spell_warl_life_tap : public SpellScriptLoader
if (manaFeedVal > 0)
{
ApplyPct(manaFeedVal, mana);
CastSpellExtraArgs args(TRIGGERED_FULL_MASK);
args.AddSpellBP0(manaFeedVal);
caster->CastSpell(caster, SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2, args);
CastSpellExtraArgs manaFeedArgs(TRIGGERED_FULL_MASK);
manaFeedArgs.AddSpellBP0(manaFeedVal);
caster->CastSpell(caster, SPELL_WARLOCK_LIFE_TAP_ENERGIZE_2, manaFeedArgs);
}
}
}