From d347fc24eca037f2755eba72115d2faeed3157f3 Mon Sep 17 00:00:00 2001 From: trickerer Date: Sat, 9 Nov 2024 14:55:13 +0700 Subject: [PATCH] NPCBots: Silence some MSVC warnings --- src/server/game/AI/NpcBots/bot_ai.cpp | 30 +++++++++++------------ src/server/game/AI/NpcBots/botdatamgr.cpp | 6 ++--- src/server/game/AI/NpcBots/botmgr.cpp | 22 ++++++++--------- src/server/game/AI/NpcBots/botmgr.h | 8 +++--- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/server/game/AI/NpcBots/bot_ai.cpp b/src/server/game/AI/NpcBots/bot_ai.cpp index 3b55e5c00592c..1f9e074be2f4d 100644 --- a/src/server/game/AI/NpcBots/bot_ai.cpp +++ b/src/server/game/AI/NpcBots/bot_ai.cpp @@ -155,7 +155,7 @@ struct TSpellSummary }; extern TSpellSummary* SpellSummary; -void ApplyBotPercentModFloatVar(float &var, float val, bool apply) +static void ApplyBotPercentModFloatVar(float &var, float val, bool apply) { var *= (apply ? ((100.f + val) / 100.f) : (100.f / (100.f + val))); } @@ -2913,7 +2913,7 @@ void bot_ai::SetStats(bool force) //HIT if (CanMiss()) { - value = IAmFree() ? mylevel / 8 : 0; // +10%/+0% at 80 + value = float(IAmFree() ? mylevel / 8 : 0); // +10%/+0% at 80 //32.5 HR = 1% hit at 80 tempval = _getTotalBotStat(BOT_STAT_MOD_HIT_MELEE_RATING) + _getTotalBotStat(BOT_STAT_MOD_HIT_RANGED_RATING) + _getTotalBotStat(BOT_STAT_MOD_HIT_SPELL_RATING) + _getTotalBotStat(BOT_STAT_MOD_HIT_RATING); tempval += me->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_RATING, (1 << CR_HIT_MELEE) | (1 << CR_HIT_RANGED) | (1 << CR_HIT_SPELL)); @@ -2954,7 +2954,7 @@ void bot_ai::SetStats(bool force) hit = 100.0f; //ARMOR PENETRATION - value = IAmFree() ? 5 + mylevel / 4 : 0; // 25%/0% at 80 + value = float(IAmFree() ? 5 + mylevel / 4 : 0); // 25%/0% at 80 //? APR = 1% armor ignored at 80 tempval = _getTotalBotStat(BOT_STAT_MOD_ARMOR_PENETRATION_RATING); tempval += me->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_RATING, (1 << CR_ARMOR_PENETRATION)); @@ -2971,7 +2971,7 @@ void bot_ai::SetStats(bool force) armor_pen = value; //EXPERTISE - value = IAmFree() ? mylevel / 2 : 0; // -10%/-0% at 80 + value = float(IAmFree() ? mylevel / 2 : 0); // -10%/-0% at 80 //~8.0 ER = 1 expertise at 80 tempval = _getTotalBotStat(BOT_STAT_MOD_EXPERTISE_RATING); tempval += me->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_RATING, (1 << CR_EXPERTISE)); @@ -3017,7 +3017,7 @@ void bot_ai::SetStats(bool force) //CRIT if (CanCrit()) { - value = IAmFree() ? mylevel / 4 : 0; // +20%/+0% at 80 + value = float(IAmFree() ? mylevel / 4 : 0); // +20%/+0% at 80 tempval = value; GtChanceToMeleeCritBaseEntry const* critBaseMelee = sGtChanceToMeleeCritBaseStore.LookupEntry(GetPlayerClass()-1); @@ -3167,7 +3167,7 @@ void bot_ai::SetStats(bool force) //PARRY if (CanParry()) { - value = 5.0f + (IAmFree() ? mylevel / 8 : 0); // +10%/+0% at 80 + value = 5.0f + float(IAmFree() ? mylevel / 8 : 0); // +10%/+0% at 80 if (mylevel >= 10) { @@ -3207,7 +3207,7 @@ void bot_ai::SetStats(bool force) //DODGE if (CanDodge()) { - value = 5.0f + (IAmFree() ? mylevel / 8 : 0); // +10%/+0% at 80 + value = 5.0f + float(IAmFree() ? mylevel / 8 : 0); // +10%/+0% at 80 if (GtChanceToMeleeCritEntry const* dodgeRatio = sGtChanceToMeleeCritStore.LookupEntry((GetPlayerClass()-1)*GT_MAX_LEVEL + mylevel-1)) value += _getTotalBotStat(BOT_STAT_MOD_AGILITY) * dodgeRatio->Data * 100.0f; @@ -3261,7 +3261,7 @@ void bot_ai::SetStats(bool force) //BLOCK if (IsBlockingClass(_botclass)) { - value = 5.0f + (IAmFree() ? mylevel / 4 : 0); // +20%/+0% at 80 + value = 5.0f + float(IAmFree() ? mylevel / 4 : 0); // +20%/+0% at 80 //16.5 BR = 1% block at 80 tempval = _getTotalBotStat(BOT_STAT_MOD_BLOCK_RATING); @@ -4566,7 +4566,7 @@ std::tuple bot_ai::_getTargets(bool byspell, bool ranged, bool &re bool checkSecondary = !IsRanged() && HasBotCommandState(BOT_COMMAND_STAY); for (Unit* un : unitList) { - uint32 res = !CanBotAttack(un, byspell) ? (checkSecondary && CanBotAttack(un, byspell, checkSecondary)) ? 2 : 0 : 1; + std::size_t res = !CanBotAttack(un, byspell) ? (checkSecondary && CanBotAttack(un, byspell, checkSecondary)) ? 2 : 0 : 1; switch (res) { case 1: case 2: @@ -5601,7 +5601,7 @@ void bot_ai::GetInPosition(bool force, Unit* newtarget, Position* mypos) { //do not allow constant runaway from player if (!force && newtarget->GetTypeId() == TYPEID_PLAYER && - me->GetDistance(newtarget) < 6 + urand(followdist/4, followdist/3)) + me->GetDistance(newtarget) < float(6 + urand(followdist/4, followdist/3))) return; if (!mypos) @@ -6233,7 +6233,7 @@ bool bot_ai::IsPotionSpell(uint32 spellId) const return spellId == GetPotion(true) || spellId == GetPotion(false); } -/*static */BotItemUseSpellTargeting SelectTargeTypetForItemSpell(uint32 spellId, Unit const* caster) +static BotItemUseSpellTargeting SelectTargeTypetForItemSpell(uint32 spellId, Unit const* caster) { SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); if (!spellInfo || spellInfo->CalcCastTime() > 1500) @@ -7197,7 +7197,7 @@ void bot_ai::_OnManaRegenUpdate() const { //regen_normal uint8 mylevel = me->GetLevel(); - float value = (IAmFree() && _botclass != BOT_CLASS_SPHYNX) ? mylevel/2 : 0; //200/0 mp5 at 80 + float value = float((IAmFree() && _botclass != BOT_CLASS_SPHYNX) ? mylevel / 2 : 0); //200/0 mp5 at 80 float power_regen_mp5; int32 modManaRegenInterrupt; @@ -9790,7 +9790,7 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32 BotBankItemContainer::const_iterator bcit = botBankItems->cbegin(); size_t i = 0; - for (; i < page * items_per_page && i < botBankItems->size(); ++i, ++bcit); + for (; i < size_t(page * items_per_page) && i < botBankItems->size(); ++i, ++bcit); for (; i < botBankItems->size() && counter < items_per_page; ++i, ++bcit) { Item const* item = *bcit; @@ -9817,7 +9817,7 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32 if (page > 0) AddGossipItemFor(player, GOSSIP_ICON_TALK, LocalizedNpcText(player, BOT_TEXT_PREVIOUS_PAGE), GOSSIP_SENDER_EQUIPMENT_BANK_WITHDRAW, action - 1); - if (botBankItems->size() > (page + 1) * items_per_page) + if (uint32(botBankItems->size()) > (page + 1) * items_per_page) AddGossipItemFor(player, GOSSIP_ICON_TALK, LocalizedNpcText(player, BOT_TEXT_NEXT_PAGE), GOSSIP_SENDER_EQUIPMENT_BANK_WITHDRAW, action + 1); AddGossipItemFor(player, GOSSIP_ICON_CHAT, LocalizedNpcText(player, BOT_TEXT_BACK), GOSSIP_SENDER_EQUIPMENT_BANK_MENU, GOSSIP_ACTION_INFO_DEF + 1); break; @@ -18112,7 +18112,7 @@ bool bot_ai::GlobalUpdate(uint32 diff) { float speed = 0.0f; _calculatePos(mmover, movepos, &speed); - float maxdist = std::max((mmover->IsPlayer() ? mmover->ToPlayer()->GetBotMgr()->GetBotFollowDist() : BotMgr::GetBotFollowDistMax() / 2) * + float maxdist = std::max((mmover->IsPlayer() ? float(mmover->ToPlayer()->GetBotMgr()->GetBotFollowDist()) : BotMgr::GetBotFollowDistMax() / 2.f) * ((mmover->m_movementInfo.GetMovementFlags() & MOVEMENTFLAG_FORWARD) ? 0.125f : mmover->isMoving() ? 0.03125f : 0.25f), 3.f); Position destPos; if (me->isMoving()) diff --git a/src/server/game/AI/NpcBots/botdatamgr.cpp b/src/server/game/AI/NpcBots/botdatamgr.cpp index ff6c0f2ad097c..04b5f4b40364b 100644 --- a/src/server/game/AI/NpcBots/botdatamgr.cpp +++ b/src/server/game/AI/NpcBots/botdatamgr.cpp @@ -532,14 +532,14 @@ struct WanderingBotsGenerator return false; uint32 total_bots_in_brackets = 0; - for (size_t k = 0; k < BracketsCount; ++k) + for (size_t k = 0; k < BRACKETS_COUNT; ++k) { if (!bracketPcts[k]) continue; bots_per_bracket[k] = CalculatePct(count, bracketPcts[k]); total_bots_in_brackets += bots_per_bracket[k]; } - for (int32 j = BracketsCount - 1; j >= 0; --j) + for (int32 j = BRACKETS_COUNT - 1; j >= 0; --j) { if (bots_per_bracket[j]) { @@ -550,7 +550,7 @@ struct WanderingBotsGenerator std::vector brackets_shuffled; brackets_shuffled.reserve(count); - for (uint8 bracket = 0; bracket < BracketsCount; ++bracket) + for (uint8 bracket = 0; bracket < BRACKETS_COUNT; ++bracket) { while (bots_per_bracket[bracket]) { diff --git a/src/server/game/AI/NpcBots/botmgr.cpp b/src/server/game/AI/NpcBots/botmgr.cpp index 3575961414efe..689b5de845bfe 100644 --- a/src/server/game/AI/NpcBots/botmgr.cpp +++ b/src/server/game/AI/NpcBots/botmgr.cpp @@ -456,7 +456,7 @@ void BotMgr::LoadConfig(bool reload) _max_npcbots = {}; std::string max_npcbots_by_levels = sConfigMgr->GetStringDefault("NpcBot.MaxBots", "1,1,1,1,1,1,1,1,1"); std::vector toks0 = Bcore::Tokenize(max_npcbots_by_levels, ',', false); - ASSERT(toks0.size() == BracketsCount, "NpcBot.MaxBots must have exactly %u values", uint32(BracketsCount)); + ASSERT(toks0.size() == BRACKETS_COUNT, "NpcBot.MaxBots must have exactly %u values", uint32(BRACKETS_COUNT)); for (decltype(toks0)::size_type i = 0; i != toks0.size(); ++i) { Optional val = Bcore::StringTo(toks0[i]); @@ -483,7 +483,7 @@ void BotMgr::LoadConfig(bool reload) _mult_dmg_levels.clear(); std::string mult_dps_by_levels = sConfigMgr->GetStringDefault("NpcBot.Mult.Damage.Levels", "1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0"); std::vector toks1 = Bcore::Tokenize(mult_dps_by_levels, ',', false); - ASSERT(toks1.size() >= BracketsCount, "NpcBot.Mult.Damage.Levels must have at least %u values", uint32(BracketsCount)); + ASSERT(toks1.size() >= BRACKETS_COUNT, "NpcBot.Mult.Damage.Levels must have at least %u values", uint32(BRACKETS_COUNT)); for (decltype(toks1)::size_type i = 0; i != toks1.size(); ++i) { Optional val = Bcore::StringTo(toks1[i]); @@ -497,7 +497,7 @@ void BotMgr::LoadConfig(bool reload) _mult_heal_levels.clear(); std::string mult_healing_by_levels = sConfigMgr->GetStringDefault("NpcBot.Mult.Healing.Levels", "1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0"); std::vector toks5 = Bcore::Tokenize(mult_healing_by_levels, ',', false); - ASSERT(toks5.size() >= BracketsCount, "NpcBot.Mult.Healing.Levels must have at least %u values", uint32(BracketsCount)); + ASSERT(toks5.size() >= BRACKETS_COUNT, "NpcBot.Mult.Healing.Levels must have at least %u values", uint32(BRACKETS_COUNT)); for (decltype(toks5)::size_type i = 0; i != toks5.size(); ++i) { Optional val = Bcore::StringTo(toks5[i]); @@ -511,7 +511,7 @@ void BotMgr::LoadConfig(bool reload) _mult_hp_levels.clear(); std::string mult_hp_by_levels = sConfigMgr->GetStringDefault("NpcBot.Mult.HP.Levels", "1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0"); std::vector toks6 = Bcore::Tokenize(mult_hp_by_levels, ',', false); - ASSERT(toks6.size() >= BracketsCount, "NpcBot.Mult.HP.Levels must have at least %u values", uint32(BracketsCount)); + ASSERT(toks6.size() >= BRACKETS_COUNT, "NpcBot.Mult.HP.Levels must have at least %u values", uint32(BRACKETS_COUNT)); for (decltype(toks6)::size_type i = 0; i != toks6.size(); ++i) { Optional val = Bcore::StringTo(toks6[i]); @@ -525,7 +525,7 @@ void BotMgr::LoadConfig(bool reload) _mult_mp_levels.clear(); std::string mult_mp_by_levels = sConfigMgr->GetStringDefault("NpcBot.Mult.MP.Levels", "1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0"); std::vector toks7 = Bcore::Tokenize(mult_mp_by_levels, ',', false); - ASSERT(toks7.size() >= BracketsCount, "NpcBot.Mult.MP.Levels must have at least %u values", uint32(BracketsCount)); + ASSERT(toks7.size() >= BRACKETS_COUNT, "NpcBot.Mult.MP.Levels must have at least %u values", uint32(BRACKETS_COUNT)); for (decltype(toks7)::size_type i = 0; i != toks7.size(); ++i) { Optional val = Bcore::StringTo(toks7[i]); @@ -539,7 +539,7 @@ void BotMgr::LoadConfig(bool reload) _botwanderer_pct_level_brackets = {}; std::string wanderers_by_levels = sConfigMgr->GetStringDefault("NpcBot.WanderingBots.Continents.Levels", "20,15,15,10,10,15,15,0,0"); std::vector toks2 = Bcore::Tokenize(wanderers_by_levels, ',', false); - ASSERT(toks2.size() == BracketsCount, "NpcBot.WanderingBots.Continents.Levels must have exactly %u values", uint32(BracketsCount)); + ASSERT(toks2.size() == BRACKETS_COUNT, "NpcBot.WanderingBots.Continents.Levels must have exactly %u values", uint32(BRACKETS_COUNT)); uint32 total_pct = 0; for (decltype(toks2)::size_type i = 0; i != toks2.size(); ++i) { @@ -602,7 +602,7 @@ void BotMgr::LoadConfig(bool reload) _botwanderer_itemlvl_level_brackets = {}; std::string itemlevel_by_levels = sConfigMgr->GetStringDefault("NpcBot.WanderingBots.MaxItemLevel.Levels", "0,0,0,0,0,0,0,0,0"); std::vector tok8 = Bcore::Tokenize(itemlevel_by_levels, ',', false); - ASSERT(tok8.size() == BracketsCount, "NpcBot.WanderingBots.MaxItemLevel.Levels must have exactly %u values", uint32(BracketsCount)); + ASSERT(tok8.size() == BRACKETS_COUNT, "NpcBot.WanderingBots.MaxItemLevel.Levels must have exactly %u values", uint32(BRACKETS_COUNT)); for (decltype(tok8)::size_type i = 0; i != tok8.size(); ++i) { Optional val = Bcore::StringTo(tok8[i]); @@ -1089,7 +1089,7 @@ uint8 BotMgr::GetNpcBotMountLevel100() uint8 BotMgr::GetMaxNpcBots(uint8 level) { - return _max_npcbots[std::min(BracketsCount - 1, level / 10)]; + return _max_npcbots[std::min(BRACKETS_COUNT - 1, level / 10)]; } int32 BotMgr::GetBotInfoPacketsLimit() @@ -2235,14 +2235,14 @@ std::string BotMgr::GetTargetIconString(uint8 icon_idx) const { std::ostringstream ss; ss << "|TInterface\\TargetingFrame\\UI-RaidTargetingIcon_" << uint32(icon_idx + 1) << ":12|t"; - if (size_t(icon_idx) < TargetIconNamesCacheSize) + if (size_t(icon_idx) < TARGET_ICON_NAMES_CACHE_SIZE) ss << _targetIconNamesCache[icon_idx]; return ss.str(); } void BotMgr::UpdateTargetIconName(uint8 id, std::string const& name) { - if (id >= TargetIconNamesCacheSize) + if (id >= TARGET_ICON_NAMES_CACHE_SIZE) return; _targetIconNamesCache[id] = name; @@ -3142,7 +3142,7 @@ PctBrackets BotMgr::GetBotWandererLevelBrackets() } uint32 BotMgr::GetBotWandererMaxItemLevel(uint8 level) { - return _botwanderer_itemlvl_level_brackets[std::min(BracketsCount - 1, level / 10)]; + return _botwanderer_itemlvl_level_brackets[std::min(BRACKETS_COUNT - 1, level / 10)]; } float BotMgr::GetBotDamageModByClass(uint8 botclass) { diff --git a/src/server/game/AI/NpcBots/botmgr.h b/src/server/game/AI/NpcBots/botmgr.h index 86c1f1f124027..3ebb97eaa476c 100644 --- a/src/server/game/AI/NpcBots/botmgr.h +++ b/src/server/game/AI/NpcBots/botmgr.h @@ -33,8 +33,8 @@ enum BattlegroundTypeId : uint32; enum CurrentSpellTypes : uint8; enum DamageEffectType : uint8; -constexpr size_t TargetIconNamesCacheSize = 8u; // Group.h TARGETICONCOUNT -constexpr size_t BracketsCount = DEFAULT_MAX_LEVEL / 10 + 1; //0-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-83 +constexpr size_t TARGET_ICON_NAMES_CACHE_SIZE = 8u; // Group.h TARGETICONCOUNT +constexpr size_t BRACKETS_COUNT = DEFAULT_MAX_LEVEL / 10 + 1; //0-9, 10-19, 20-29, 30-39, 40-49, 50-59, 60-69, 70-79, 80-83 enum BotMgrDataFlags : uint32 { @@ -95,7 +95,7 @@ enum BotAttackAngle typedef std::unordered_map BotMap; template -using BotBrackets = std::array; +using BotBrackets = std::array; typedef BotBrackets LvlBrackets; typedef BotBrackets PctBrackets; typedef BotBrackets ItemLvlBrackets; @@ -363,7 +363,7 @@ class TC_GAME_API BotMgr AoeSpotsVec _aoespots; - std::array _targetIconNamesCache; + std::array _targetIconNamesCache; }; void AddNpcBotScripts();