Skip to content

Commit

Permalink
NPCBots: Silence some MSVC warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
trickerer committed Nov 9, 2024
1 parent 4419045 commit d347fc2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
30 changes: 15 additions & 15 deletions src/server/game/AI/NpcBots/bot_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -4566,7 +4566,7 @@ std::tuple<Unit*, Unit*> 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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -18112,7 +18112,7 @@ bool bot_ai::GlobalUpdate(uint32 diff)
{
float speed = 0.0f;
_calculatePos(mmover, movepos, &speed);
float maxdist = std::max<float>((mmover->IsPlayer() ? mmover->ToPlayer()->GetBotMgr()->GetBotFollowDist() : BotMgr::GetBotFollowDistMax() / 2) *
float maxdist = std::max<float>((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())
Expand Down
6 changes: 3 additions & 3 deletions src/server/game/AI/NpcBots/botdatamgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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])
{
Expand All @@ -550,7 +550,7 @@ struct WanderingBotsGenerator

std::vector<uint8> 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])
{
Expand Down
22 changes: 11 additions & 11 deletions src/server/game/AI/NpcBots/botmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string_view> 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<uint8> val = Bcore::StringTo<uint8>(toks0[i]);
Expand All @@ -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<std::string_view> 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<float> val = Bcore::StringTo<float>(toks1[i]);
Expand All @@ -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<std::string_view> 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<float> val = Bcore::StringTo<float>(toks5[i]);
Expand All @@ -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<std::string_view> 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<float> val = Bcore::StringTo<float>(toks6[i]);
Expand All @@ -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<std::string_view> 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<float> val = Bcore::StringTo<float>(toks7[i]);
Expand All @@ -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<std::string_view> 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)
{
Expand Down Expand Up @@ -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<std::string_view> 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<uint32> val = Bcore::StringTo<uint32>(tok8[i]);
Expand Down Expand Up @@ -1089,7 +1089,7 @@ uint8 BotMgr::GetNpcBotMountLevel100()

uint8 BotMgr::GetMaxNpcBots(uint8 level)
{
return _max_npcbots[std::min<size_t>(BracketsCount - 1, level / 10)];
return _max_npcbots[std::min<size_t>(BRACKETS_COUNT - 1, level / 10)];
}

int32 BotMgr::GetBotInfoPacketsLimit()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3142,7 +3142,7 @@ PctBrackets BotMgr::GetBotWandererLevelBrackets()
}
uint32 BotMgr::GetBotWandererMaxItemLevel(uint8 level)
{
return _botwanderer_itemlvl_level_brackets[std::min<size_t>(BracketsCount - 1, level / 10)];
return _botwanderer_itemlvl_level_brackets[std::min<size_t>(BRACKETS_COUNT - 1, level / 10)];
}
float BotMgr::GetBotDamageModByClass(uint8 botclass)
{
Expand Down
8 changes: 4 additions & 4 deletions src/server/game/AI/NpcBots/botmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -95,7 +95,7 @@ enum BotAttackAngle

typedef std::unordered_map<ObjectGuid /*guid*/, Creature* /*bot*/> BotMap;
template<typename U>
using BotBrackets = std::array<U, BracketsCount>;
using BotBrackets = std::array<U, BRACKETS_COUNT>;
typedef BotBrackets<uint8> LvlBrackets;
typedef BotBrackets<uint32> PctBrackets;
typedef BotBrackets<uint32> ItemLvlBrackets;
Expand Down Expand Up @@ -363,7 +363,7 @@ class TC_GAME_API BotMgr

AoeSpotsVec _aoespots;

std::array<std::string, TargetIconNamesCacheSize> _targetIconNamesCache;
std::array<std::string, TARGET_ICON_NAMES_CACHE_SIZE> _targetIconNamesCache;
};

void AddNpcBotScripts();
Expand Down

0 comments on commit d347fc2

Please sign in to comment.