aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorazazel <none@none>2010-08-26 15:54:56 +0600
committerazazel <none@none>2010-08-26 15:54:56 +0600
commit5fa14f58dceb3be78a5964c09eb17dc358c10c7b (patch)
tree1c7b2c1d7f19ca7d56a602b023a1d3b724f2e72c /src
parent6036166716d2d2cdfa0f5c27f8cfb7e1e65b0c8f (diff)
Core/Cleanup:
* move repeating code into separate method for storing locale strings in ObjectMgr (copy/paste sucks, you know) * fix 'signed/unsigned' warnings (at least in VS) * fix some other warnings and cleanup relative code --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/CreatureAISelector.cpp4
-rw-r--r--src/server/game/Achievements/AchievementMgr.h4
-rw-r--r--src/server/game/Entities/Creature/Creature.h10
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h4
-rw-r--r--src/server/game/Entities/Item/ItemPrototype.h6
-rw-r--r--src/server/game/Entities/Player/Player.cpp12
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp67
-rw-r--r--src/server/game/Events/GameEventMgr.cpp33
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp335
-rw-r--r--src/server/game/Globals/ObjectMgr.h6
-rw-r--r--src/server/game/Groups/Group.cpp2
-rw-r--r--src/server/game/Quests/QuestDef.h16
-rw-r--r--src/server/game/Server/Protocol/Handlers/LootHandler.cpp2
-rw-r--r--src/server/game/Server/Protocol/Handlers/NPCHandler.h6
-rw-r--r--src/server/game/Server/Protocol/Handlers/QueryHandler.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp14
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp10
-rw-r--r--src/server/game/Spells/Spell.cpp8
-rw-r--r--src/server/game/Spells/SpellEffects.cpp21
-rw-r--r--src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp2
-rw-r--r--src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp6
-rw-r--r--src/server/shared/Common.h2
23 files changed, 195 insertions, 379 deletions
diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp
index 14e85959941..a83069f6efa 100644
--- a/src/server/game/AI/CreatureAISelector.cpp
+++ b/src/server/game/AI/CreatureAISelector.cpp
@@ -110,9 +110,9 @@ namespace FactorySelector
/* if (mv_factory == NULL)
{
int best_val = -1;
- std::vector<std::string> l;
+ StringVector l;
mv_registry.GetRegisteredItems(l);
- for (std::vector<std::string>::iterator iter = l.begin(); iter != l.end(); ++iter)
+ for (StringVector::iterator iter = l.begin(); iter != l.end(); ++iter)
{
const MovementGeneratorCreator *factory = mv_registry.GetRegistryItem((*iter).c_str());
const SelectableMovement *p = dynamic_cast<const SelectableMovement *>(factory);
diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h
index 7c6d9f0b003..ea8c01a9f85 100644
--- a/src/server/game/Achievements/AchievementMgr.h
+++ b/src/server/game/Achievements/AchievementMgr.h
@@ -216,8 +216,8 @@ typedef std::map<uint32,AchievementReward> AchievementRewards;
struct AchievementRewardLocale
{
- std::vector<std::string> subject;
- std::vector<std::string> text;
+ StringVector subject;
+ StringVector text;
};
typedef std::map<uint32,AchievementRewardLocale> AchievementRewardLocales;
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index c476471c4fb..6fce4565222 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -205,19 +205,19 @@ typedef UNORDERED_MAP<uint16, CreatureBaseStats> CreatureBaseStatsMap;
struct CreatureLocale
{
- std::vector<std::string> Name;
- std::vector<std::string> SubName;
+ StringVector Name;
+ StringVector SubName;
};
struct GossipMenuItemsLocale
{
- std::vector<std::string> OptionText;
- std::vector<std::string> BoxText;
+ StringVector OptionText;
+ StringVector BoxText;
};
struct PointOfInterestLocale
{
- std::vector<std::string> IconName;
+ StringVector IconName;
};
struct EquipmentInfo
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 2b48c354c90..4dd93e24519 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -537,8 +537,8 @@ union GameObjectValue
struct GameObjectLocale
{
- std::vector<std::string> Name;
- std::vector<std::string> CastBarCaption;
+ StringVector Name;
+ StringVector CastBarCaption;
};
// client side GO show states
diff --git a/src/server/game/Entities/Item/ItemPrototype.h b/src/server/game/Entities/Item/ItemPrototype.h
index 38f1a2d0dc4..b9563e153cc 100644
--- a/src/server/game/Entities/Item/ItemPrototype.h
+++ b/src/server/game/Entities/Item/ItemPrototype.h
@@ -735,8 +735,8 @@ struct ItemPrototype
struct ItemLocale
{
- std::vector<std::string> Name;
- std::vector<std::string> Description;
+ StringVector Name;
+ StringVector Description;
};
struct ItemSetNameEntry
@@ -747,7 +747,7 @@ struct ItemSetNameEntry
struct ItemSetNameLocale
{
- std::vector<std::string> Name;
+ StringVector Name;
};
// GCC have alternative #pragma pack() syntax and old gcc version not support pack(pop), also any gcc version not support it at some platform
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 1375afe68b6..052fb1571a0 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -15518,15 +15518,15 @@ bool Player::HasQuestForItem(uint32 itemid) const
ItemPrototype const *pProto = sObjectMgr.GetItemPrototype(itemid);
// 'unique' item
- if (pProto->MaxCount && GetItemCount(itemid,true) < pProto->MaxCount)
+ if (pProto->MaxCount && int32(GetItemCount(itemid, true)) < pProto->MaxCount)
return true;
// allows custom amount drop when not 0
if (qinfo->ReqSourceCount[j])
{
- if (GetItemCount(itemid,true) < qinfo->ReqSourceCount[j])
+ if (GetItemCount(itemid, true) < qinfo->ReqSourceCount[j])
return true;
- } else if (GetItemCount(itemid,true) < pProto->Stackable)
+ } else if (int32(GetItemCount(itemid, true)) < pProto->Stackable)
return true;
}
}
@@ -15614,13 +15614,9 @@ void Player::SendQuestConfirmAccept(const Quest* pQuest, Player* pReceiver)
int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex();
if (loc_idx >= 0)
- {
if (const QuestLocale* pLocale = sObjectMgr.GetQuestLocale(pQuest->GetQuestId()))
- {
- if (pLocale->Title.size() > loc_idx && !pLocale->Title[loc_idx].empty())
+ if (int(pLocale->Title.size()) > loc_idx && !pLocale->Title[loc_idx].empty())
strTitle = pLocale->Title[loc_idx];
- }
- }
WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + strTitle.size() + 8));
data << uint32(pQuest->GetQuestId());
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 02e7ab3829b..992c7061fd9 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -40,7 +40,7 @@ inline bool _ModifyUInt32(bool apply, uint32& baseValue, int32& amount)
else
{
// Make sure we do not get uint32 overflow.
- if (amount > baseValue)
+ if (amount > int32(baseValue))
amount = baseValue;
baseValue -= amount;
}
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 95beb3b34d6..ba69b702b21 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -1091,12 +1091,12 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
// Spell weapon based damage CAN BE crit & blocked at same time
if (blocked)
{
- damageInfo->blocked = uint32(pVictim->GetShieldBlockValue());
+ damageInfo->blocked = pVictim->GetShieldBlockValue();
//double blocked amount if block is critical
if (pVictim->isBlockCritical())
- damageInfo->blocked+=damageInfo->blocked;
- if (damage < damageInfo->blocked)
- damageInfo->blocked = damage;
+ damageInfo->blocked += damageInfo->blocked;
+ if (damage < int32(damageInfo->blocked))
+ damageInfo->blocked = uint32(damage);
damage -= damageInfo->blocked;
}
@@ -1941,7 +1941,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
pVictim->CastCustomSpell(pVictim, 66235, &healAmount, NULL, NULL, true);
pVictim->ToPlayer()->AddSpellCooldown(66235,0,time(NULL) + 120);
}
- else if (remainingHealth < allowedHealth)
+ else if (remainingHealth < int32(allowedHealth))
{
// Reduce damage that brings us under 35% (or full damage if we are already under 35%) by x%
uint32 damageToReduce = (pVictim->GetHealth() < allowedHealth)
@@ -2203,7 +2203,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
RemainingDamage += auraAbsorbMod * TotalAbsorb / 100;
// Apply death prevention spells effects
- if (preventDeathSpell && RemainingDamage >= pVictim->GetHealth())
+ if (preventDeathSpell && RemainingDamage >= int32(pVictim->GetHealth()))
{
switch(preventDeathSpell->SpellFamilyName)
{
@@ -2930,44 +2930,44 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
if (Player *modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spell->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance);
// Increase from attacker SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT auras
- modHitChance+=GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask);
+ modHitChance += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_INCREASES_SPELL_PCT_TO_HIT, schoolMask);
// Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras
- modHitChance+= pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
+ modHitChance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
// Reduce spell hit chance for Area of effect spells from victim SPELL_AURA_MOD_AOE_AVOIDANCE aura
if (IsAreaOfEffectSpell(spell))
- modHitChance-=pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE);
+ modHitChance -= pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_AOE_AVOIDANCE);
int32 HitChance = modHitChance * 100;
// Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings
- HitChance += int32(m_modSpellHitChance*100.0f);
+ HitChance += int32(m_modSpellHitChance * 100.0f);
// Decrease hit chance from victim rating bonus
if (pVictim->GetTypeId() == TYPEID_PLAYER)
- HitChance -= int32(pVictim->ToPlayer()->GetRatingBonusValue(CR_HIT_TAKEN_SPELL)*100.0f);
+ HitChance -= int32(pVictim->ToPlayer()->GetRatingBonusValue(CR_HIT_TAKEN_SPELL) * 100.0f);
- if (HitChance < 100)
- HitChance = 100;
+ if (HitChance < 100)
+ HitChance = 100;
else if (HitChance > 10000)
HitChance = 10000;
int32 tmp = 10000 - HitChance;
- uint32 rand = urand(0,10000);
+ int32 rand = irand(0, 10000);
if (rand < tmp)
return SPELL_MISS_MISS;
// Chance resist mechanic (select max value from every mechanic spell effect)
- int32 resist_chance = pVictim->GetMechanicResistChance(spell)*100;
+ int32 resist_chance = pVictim->GetMechanicResistChance(spell) * 100;
tmp += resist_chance;
// Chance resist debuff
if (!IsPositiveSpell(spell->Id))
{
bool bNegativeAura = false;
- for (uint8 I = 0; I < 3; I++)
+ for (uint8 i = 0; i < 3; ++i)
{
- if (spell->EffectApplyAuraName[I] != 0)
+ if (spell->EffectApplyAuraName[i] != 0)
{
bNegativeAura = true;
break;
@@ -2986,10 +2986,10 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell)
return SPELL_MISS_RESIST;
// cast by caster in front of victim
- if (pVictim->HasInArc(M_PI,this) || pVictim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
+ if (pVictim->HasInArc(M_PI, this) || pVictim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION))
{
- int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS)*100;
- tmp+=deflect_chance;
+ int32 deflect_chance = pVictim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
+ tmp += deflect_chance;
if (rand < tmp)
return SPELL_MISS_DEFLECT;
}
@@ -5481,12 +5481,13 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
case 25988:
{
// return damage % to attacker but < 50% own total health
- basepoints0 = int32((triggerAmount* damage) /100);
+ basepoints0 = int32((triggerAmount * damage) /100);
- if (basepoints0 > GetMaxHealth()/2)
- basepoints0 = GetMaxHealth()/2;
+ int32 halfMaxHealth = int32(CountPctFromMaxHealth(50));
+ if (basepoints0 > halfMaxHealth)
+ basepoints0 = halfMaxHealth;
- sLog.outDebug("DEBUG LINE: Data about Eye for an Eye ID %u, damage taken %u, unit max health %u, damage done %u", dummySpell->Id, damage, GetMaxHealth(),basepoints0);
+ sLog.outDebug("DEBUG LINE: Data about Eye for an Eye ID %u, damage taken %u, unit max health %u, damage done %u", dummySpell->Id, damage, GetMaxHealth(), basepoints0);
triggered_spell_id = 25997;
@@ -6179,7 +6180,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
if (procSpell && procSpell->Id == 27285)
return false;
// if damage is more than need or target die from damage deal finish spell
- if (triggeredByAura->GetAmount() <= damage || GetHealth() <= damage)
+ if (triggeredByAura->GetAmount() <= int32(damage) || GetHealth() <= damage)
{
// remember guid before aura delete
uint64 casterGuid = triggeredByAura->GetCasterGUID();
@@ -6198,10 +6199,10 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
return true;
}
// Seed of Corruption (Mobs cast) - no die req
- if (dummySpell->SpellFamilyFlags.IsEqual(0,0,0) && dummySpell->SpellIconID == 1932)
+ if (dummySpell->SpellFamilyFlags.IsEqual(0, 0, 0) && dummySpell->SpellIconID == 1932)
{
// if damage is more than need deal finish spell
- if (triggeredByAura->GetAmount() <= damage)
+ if (triggeredByAura->GetAmount() <= int32(damage))
{
// remember guid before aura delete
uint64 casterGuid = triggeredByAura->GetCasterGUID();
@@ -12130,7 +12131,7 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
uint32 invLevel = 0;
Unit::AuraEffectList const& iAuras = u->GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY);
for (Unit::AuraEffectList::const_iterator itr = iAuras.begin(); itr != iAuras.end(); ++itr)
- if (uint8((*itr)->GetMiscValue()) == i && invLevel < (*itr)->GetAmount())
+ if (uint8((*itr)->GetMiscValue()) == i && int32(invLevel) < (*itr)->GetAmount())
invLevel = (*itr)->GetAmount();
// find invisibility detect level
@@ -12143,7 +12144,7 @@ bool Unit::canDetectInvisibilityOf(Unit const* u) const
{
Unit::AuraEffectList const& dAuras = GetAuraEffectsByType(SPELL_AURA_MOD_INVISIBILITY_DETECTION);
for (Unit::AuraEffectList::const_iterator itr = dAuras.begin(); itr != dAuras.end(); ++itr)
- if (uint8((*itr)->GetMiscValue()) == i && detectLevel < (*itr)->GetAmount())
+ if (uint8((*itr)->GetMiscValue()) == i && int32(detectLevel) < (*itr)->GetAmount())
detectLevel = (*itr)->GetAmount();
}
@@ -12237,12 +12238,12 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
stack_bonus = GetTotalAuraMultiplier(SPELL_AURA_MOD_VEHICLE_SPEED_ALWAYS);
// for some spells this mod is applied on vehicle owner
- uint32 owner_speed_mod = 0;
+ int32 owner_speed_mod = 0;
if (Unit * owner = GetCharmer())
owner_speed_mod = owner->GetMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_VEHICLE_FLIGHT_SPEED);
- main_speed_mod = main_speed_mod>owner_speed_mod ? main_speed_mod : owner_speed_mod;
+ main_speed_mod = std::max(main_speed_mod, owner_speed_mod);
}
else if (IsMounted())
{
@@ -12924,7 +12925,7 @@ void Unit::IncrDiminishing(DiminishingGroup group)
{
if (i->DRGroup != group)
continue;
- if (i->hitCount < GetDiminishingReturnsMaxLevel(group))
+ if (int32(i->hitCount) < GetDiminishingReturnsMaxLevel(group))
i->hitCount += 1;
return;
}
@@ -14246,7 +14247,7 @@ void Unit::ProcDamageAndSpellFor(bool isVictim, Unit * pTarget, uint32 procFlag,
{
int32 damageLeft = triggeredByAura->GetAmount();
// No damage left
- if (damageLeft < damage)
+ if (damageLeft < int32(damage))
i->aura->Remove();
else
triggeredByAura->SetAmount(damageLeft - damage);
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index f06b1d520b2..8ed647ca364 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -408,7 +408,7 @@ void GameEventMgr::LoadFromDB()
int32 internal_event_id = mGameEvent.size() + event_id - 1;
- if (internal_event_id < 0 || internal_event_id >= mGameEventCreatureGuids.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size()))
{
sLog.outErrorDb("`game_event_creature` game event id (%i) is out of range compared to max event id in `game_event`",event_id);
continue;
@@ -457,7 +457,7 @@ void GameEventMgr::LoadFromDB()
int32 internal_event_id = mGameEvent.size() + event_id - 1;
- if (internal_event_id < 0 || internal_event_id >= mGameEventGameobjectGuids.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
{
sLog.outErrorDb("`game_event_gameobject` game event id (%i) is out of range compared to max event id in `game_event`",event_id);
continue;
@@ -1009,7 +1009,7 @@ void GameEventMgr::LoadFromDB()
int32 internal_event_id = mGameEvent.size() + event_id - 1;
- if (internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
{
sLog.outErrorDb("`game_event_pool` game event id (%i) is out of range compared to max event id in `game_event`",event_id);
continue;
@@ -1253,9 +1253,10 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
{
int32 internal_event_id = mGameEvent.size() + event_id - 1;
- if (internal_event_id < 0 || internal_event_id >= mGameEventCreatureGuids.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size()))
{
- sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventCreatureGuids.size());
+ sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")",
+ internal_event_id, mGameEventCreatureGuids.size());
return;
}
@@ -1281,9 +1282,10 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
}
}
- if (internal_event_id < 0 || internal_event_id >= mGameEventGameobjectGuids.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
{
- sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventGameobjectGuids.size());
+ sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")",
+ internal_event_id, mGameEventGameobjectGuids.size());
return;
}
@@ -1312,9 +1314,10 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
}
}
- if (internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
{
- sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventPoolIds element %u (size: " SIZEFMTD ")",internal_event_id,mGameEventPoolIds.size());
+ sLog.outError("GameEventMgr::GameEventSpawn attempt access to out of range mGameEventPoolIds element %u (size: " SIZEFMTD ")",
+ internal_event_id, mGameEventPoolIds.size());
return;
}
@@ -1326,9 +1329,10 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
{
int32 internal_event_id = mGameEvent.size() + event_id - 1;
- if (internal_event_id < 0 || internal_event_id >= mGameEventCreatureGuids.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventCreatureGuids.size()))
{
- sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventCreatureGuids.size());
+ sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventCreatureGuids element %i (size: " SIZEFMTD ")",
+ internal_event_id, mGameEventCreatureGuids.size());
return;
}
@@ -1347,9 +1351,10 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
}
}
- if (internal_event_id < 0 || internal_event_id >= mGameEventGameobjectGuids.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventGameobjectGuids.size()))
{
- sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")",internal_event_id,mGameEventGameobjectGuids.size());
+ sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventGameobjectGuids element %i (size: " SIZEFMTD ")",
+ internal_event_id, mGameEventGameobjectGuids.size());
return;
}
@@ -1367,7 +1372,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
pGameobject->AddObjectToRemoveList();
}
}
- if (internal_event_id < 0 || internal_event_id >= mGameEventPoolIds.size())
+ if (internal_event_id < 0 || internal_event_id >= int32(mGameEventPoolIds.size()))
{
sLog.outError("GameEventMgr::GameEventUnspawn attempt access to out of range mGameEventPoolIds element %u (size: " SIZEFMTD ")",internal_event_id,mGameEventPoolIds.size());
return;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index f8e3fcc9e09..d01e65f12dc 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -409,6 +409,21 @@ CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id)
return sCreatureStorage.LookupEntry<CreatureInfo>(id);
}
+void ObjectMgr::AddLocaleString(std::string& s, LocaleConstant locale, StringVector& data)
+{
+ if (!s.empty())
+ {
+ int idx = GetOrNewIndexForLocale(locale);
+ if (idx >= 0)
+ {
+ if (int(data.size()) <= idx)
+ data.resize(idx + 1);
+
+ data[idx] = s;
+ }
+ }
+}
+
void ObjectMgr::LoadCreatureLocales()
{
mCreatureLocaleMap.clear(); // need for reload case
@@ -431,30 +446,12 @@ void ObjectMgr::LoadCreatureLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
- std::string str = fields[1+2*(i-1)].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Name.size() <= idx)
- data.Name.resize(idx+1);
-
- data.Name[idx] = str;
- }
- }
- str = fields[1+2*(i-1)+1].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.SubName.size() <= idx)
- data.SubName.resize(idx+1);
+ LocaleConstant locale = (LocaleConstant) i;
+ std::string str = fields[1 + 2 * (i - 1)].GetCppString();
+ AddLocaleString(str, locale, data.Name);
- data.SubName[idx] = str;
- }
- }
+ str = fields[1 + 2 * (i - 1) + 1].GetCppString();
+ AddLocaleString(str, locale, data.SubName);
}
} while (result->NextRow());
@@ -490,30 +487,12 @@ void ObjectMgr::LoadGossipMenuItemsLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
- std::string str = fields[2+2*(i-1)].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.OptionText.size() <= idx)
- data.OptionText.resize(idx+1);
-
- data.OptionText[idx] = str;
- }
- }
- str = fields[2+2*(i-1)+1].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.BoxText.size() <= idx)
- data.BoxText.resize(idx+1);
+ LocaleConstant locale = (LocaleConstant) i;
+ std::string str = fields[2 + 2 * (i - 1)].GetCppString();
+ AddLocaleString(str, locale, data.OptionText);
- data.BoxText[idx] = str;
- }
- }
+ str = fields[2 + 2 * (i - 1) + 1].GetCppString();
+ AddLocaleString(str, locale, data.BoxText);
}
} while (result->NextRow());
@@ -544,17 +523,7 @@ void ObjectMgr::LoadPointOfInterestLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
- if (str.empty())
- continue;
-
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.IconName.size() <= idx)
- data.IconName.resize(idx+1);
-
- data.IconName[idx] = str;
- }
+ AddLocaleString(str, LocaleConstant(i), data.IconName);
}
} while (result->NextRow());
@@ -1049,14 +1018,14 @@ void ObjectMgr::LoadEquipmentTemplates()
{
sEquipmentStorage.Load();
- for (uint32 i=0; i< sEquipmentStorage.MaxEntry; ++i)
+ for (uint32 i = 0; i < sEquipmentStorage.MaxEntry; ++i)
{
EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry<EquipmentInfo>(i);
if (!eqInfo)
continue;
- for (uint8 j=0; j<3; j++)
+ for (uint8 j = 0; j < 3; ++j)
{
if (!eqInfo->equipentry[j])
continue;
@@ -1976,31 +1945,12 @@ void ObjectMgr::LoadItemLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
- std::string str = fields[1+2*(i-1)].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Name.size() <= idx)
- data.Name.resize(idx+1);
-
- data.Name[idx] = str;
- }
- }
+ LocaleConstant locale = (LocaleConstant) i;
+ std::string str = fields[1 + 2 * (i - 1)].GetCppString();
+ AddLocaleString(str, locale, data.Name);
- str = fields[1+2*(i-1)+1].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Description.size() <= idx)
- data.Description.resize(idx+1);
-
- data.Description[idx] = str;
- }
- }
+ str = fields[1 + 2 * (i - 1) + 1].GetCppString();
+ AddLocaleString(str, locale, data.Description);
}
} while (result->NextRow());
@@ -2492,17 +2442,7 @@ void ObjectMgr::LoadItemSetNameLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Name.size() <= idx)
- data.Name.resize(idx+1);
-
- data.Name[idx] = str;
- }
- }
+ AddLocaleString(str, LocaleConstant(i), data.Name);
}
} while (result->NextRow());
@@ -3751,7 +3691,7 @@ void ObjectMgr::LoadGroups()
}
uint32 diff = fields[4].GetUInt8();
- if (diff >= (mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))
+ if (diff >= uint32(mapEntry->IsRaid() ? MAX_RAID_DIFFICULTY : MAX_DUNGEON_DIFFICULTY))
{
sLog.outErrorDb("Wrong dungeon difficulty use in group_instance table: %d", diff + 1);
diff = 0; // default for both difficaly types
@@ -4495,105 +4435,32 @@ void ObjectMgr::LoadQuestLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
- std::string str = fields[1+11*(i-1)].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Title.size() <= idx)
- data.Title.resize(idx+1);
+ LocaleConstant locale = (LocaleConstant) i;
+ std::string str = fields[1 + 11 * (i - 1)].GetCppString();
+ AddLocaleString(str, locale, data.Title);
- data.Title[idx] = str;
- }
- }
- str = fields[1+11*(i-1)+1].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Details.size() <= idx)
- data.Details.resize(idx+1);
-
- data.Details[idx] = str;
- }
- }
- str = fields[1+11*(i-1)+2].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Objectives.size() <= idx)
- data.Objectives.resize(idx+1);
+ str = fields[1 + 11 * (i - 1) + 1].GetCppString();
+ AddLocaleString(str, locale, data.Details);
- data.Objectives[idx] = str;
- }
- }
- str = fields[1+11*(i-1)+3].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.OfferRewardText.size() <= idx)
- data.OfferRewardText.resize(idx+1);
+ str = fields[1 + 11 * (i - 1) + 2].GetCppString();
+ AddLocaleString(str, locale, data.Objectives);
- data.OfferRewardText[idx] = str;
- }
- }
- str = fields[1+11*(i-1)+4].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.RequestItemsText.size() <= idx)
- data.RequestItemsText.resize(idx+1);
+ str = fields[1 + 11 * (i - 1) + 3].GetCppString();
+ AddLocaleString(str, locale, data.OfferRewardText);
- data.RequestItemsText[idx] = str;
- }
- }
- str = fields[1+11*(i-1)+5].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.EndText.size() <= idx)
- data.EndText.resize(idx+1);
+ str = fields[1 + 11 * (i - 1) + 4].GetCppString();
+ AddLocaleString(str, locale, data.RequestItemsText);
- data.EndText[idx] = str;
- }
- }
- str = fields[1+11*(i-1)+6].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.CompletedText.size() <= idx)
- data.CompletedText.resize(idx+1);
+ str = fields[1 + 11 * (i - 1) + 5].GetCppString();
+ AddLocaleString(str, locale, data.EndText);
- data.CompletedText[idx] = str;
- }
- }
+ str = fields[1 + 11 * (i - 1) + 6].GetCppString();
+ AddLocaleString(str, locale, data.CompletedText);
for (uint8 k = 0; k < 4; ++k)
{
- str = fields[1+11*(i-1)+7+k].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.ObjectiveText[k].size() <= idx)
- data.ObjectiveText[k].resize(idx+1);
-
- data.ObjectiveText[k][idx] = str;
- }
- }
+ str = fields[1 + 11 * (i - 1) + 7 + k].GetCppString();
+ AddLocaleString(str, locale, data.ObjectiveText[k]);
}
}
} while (result->NextRow());
@@ -5243,17 +5110,7 @@ void ObjectMgr::LoadPageTextLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
- if (str.empty())
- continue;
-
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Text.size() <= idx)
- data.Text.resize(idx+1);
-
- data.Text[idx] = str;
- }
+ AddLocaleString(str, LocaleConstant(i), data.Text);
}
} while (result->NextRow());
@@ -5390,34 +5247,16 @@ void ObjectMgr::LoadNpcTextLocales()
NpcTextLocale& data = mNpcTextLocaleMap[entry];
- for (uint8 i=1; i<MAX_LOCALE; ++i)
+ for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
- for (uint8 j=0; j<8; ++j)
+ LocaleConstant locale = (LocaleConstant) i;
+ for (uint8 j = 0; j < 8; ++j)
{
- std::string str0 = fields[1+8*2*(i-1)+2*j].GetCppString();
- if (!str0.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Text_0[j].size() <= idx)
- data.Text_0[j].resize(idx+1);
-
- data.Text_0[j][idx] = str0;
- }
- }
- std::string str1 = fields[1+8*2*(i-1)+2*j+1].GetCppString();
- if (!str1.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Text_1[j].size() <= idx)
- data.Text_1[j].resize(idx+1);
+ std::string str0 = fields[1 + 8 * 2 * (i - 1) + 2 * j].GetCppString();
+ AddLocaleString(str0, locale, data.Text_0[j]);
- data.Text_1[j][idx] = str1;
- }
- }
+ std::string str1 = fields[1 + 8 * 2 * (i - 1) + 2 * j + 1].GetCppString();
+ AddLocaleString(str1, locale, data.Text_1[j]);
}
}
} while (result->NextRow());
@@ -6462,33 +6301,13 @@ void ObjectMgr::LoadGameObjectLocales()
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.Name.size() <= idx)
- data.Name.resize(idx+1);
-
- data.Name[idx] = str;
- }
- }
+ AddLocaleString(str, LocaleConstant(i), data.Name);
}
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
- std::string str = fields[i+(MAX_LOCALE-1)].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- if (data.CastBarCaption.size() <= idx)
- data.CastBarCaption.resize(idx+1);
-
- data.CastBarCaption[idx] = str;
- }
- }
+ std::string str = fields[i + (MAX_LOCALE - 1)].GetCppString();
+ AddLocaleString(str, LocaleConstant(i), data.CastBarCaption);
}
} while (result->NextRow());
@@ -6835,8 +6654,8 @@ void ObjectMgr::LoadPetNumber()
std::string ObjectMgr::GeneratePetName(uint32 entry)
{
- std::vector<std::string> & list0 = PetHalfName0[entry];
- std::vector<std::string> & list1 = PetHalfName1[entry];
+ StringVector & list0 = PetHalfName0[entry];
+ StringVector & list1 = PetHalfName1[entry];
if (list0.empty() || list1.empty())
{
@@ -7783,7 +7602,7 @@ int ObjectMgr::GetIndexForLocale(LocaleConstant loc)
LocaleConstant ObjectMgr::GetLocaleForIndex(int i)
{
- if (i<0 || i >= m_LocalForIndex.size())
+ if (i < 0 || i >= int(m_LocalForIndex.size()))
return LOCALE_enUS;
return m_LocalForIndex[i];
@@ -7794,12 +7613,12 @@ int ObjectMgr::GetOrNewIndexForLocale(LocaleConstant loc)
if (loc == LOCALE_enUS)
return -1;
- for (size_t i=0; i < m_LocalForIndex.size(); ++i)
+ for (size_t i = 0; i < m_LocalForIndex.size(); ++i)
if (m_LocalForIndex[i] == loc)
return i;
m_LocalForIndex.push_back(loc);
- return m_LocalForIndex.size()-1;
+ return m_LocalForIndex.size() - 1;
}
void ObjectMgr::LoadGameObjectForQuests()
@@ -7950,18 +7769,7 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
for (uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i+1].GetCppString();
- if (!str.empty())
- {
- int idx = GetOrNewIndexForLocale(LocaleConstant(i));
- if (idx >= 0)
- {
- // 0 -> default, idx in to idx+1
- if (data.Content.size() <= idx+1)
- data.Content.resize(idx+2);
-
- data.Content[idx+1] = str;
- }
- }
+ AddLocaleString(str, LocaleConstant(i), data.Content);
}
} while (result->NextRow());
@@ -7980,8 +7788,9 @@ const char *ObjectMgr::GetTrinityString(int32 entry, int locale_idx) const
// Content[0] always exist if exist TrinityStringLocale
if (TrinityStringLocale const *msl = GetTrinityStringLocale(entry))
{
- if (msl->Content.size() > locale_idx+1 && !msl->Content[locale_idx+1].empty())
- return msl->Content[locale_idx+1].c_str();
+ int idx = locale_idx + 1;
+ if (int(msl->Content.size()) > idx && !msl->Content[idx].empty())
+ return msl->Content[idx].c_str();
else
return msl->Content[0].c_str();
}
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index 8a8699b4c38..9d199edff59 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -174,7 +174,7 @@ typedef UNORDERED_MAP<uint64/*(instance,guid) pair*/,time_t> RespawnTimes;
struct TrinityStringLocale
{
- std::vector<std::string> Content; // 0 -> default, i -> i-1 locale index
+ StringVector Content; // 0 -> default, i -> i-1 locale index
};
typedef std::map<uint32,uint32> CreatureLinkedRespawnMap;
@@ -1071,6 +1071,8 @@ class ObjectMgr
int DBCLocaleIndex;
+ void AddLocaleString(std::string& s, LocaleConstant locale, StringVector& data);
+
private:
void LoadScripts(ScriptsType type);
void CheckScripts(ScriptsType type, std::set<int32>& ids);
@@ -1101,7 +1103,7 @@ class ObjectMgr
typedef std::map<uint32,int32> FishingBaseSkillMap; // [areaId][base skill level]
FishingBaseSkillMap mFishingBaseForArea;
- typedef std::map<uint32,std::vector<std::string> > HalfNameMap;
+ typedef std::map<uint32, StringVector> HalfNameMap;
HalfNameMap PetHalfName0;
HalfNameMap PetHalfName1;
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 80e998ecea4..f7cde3ae6ff 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -361,7 +361,7 @@ uint32 Group::RemoveMember(const uint64 &guid, const uint8 &method)
sLFGMgr.OfferContinue(this);
// remove member and change leader (if need) only if strong more 2 members _before_ member remove
- if (GetMembersCount() > (isBGGroup() ? 1 : 2)) // in BG group case allow 1 members group
+ if (GetMembersCount() > (isBGGroup() ? 1u : 2u)) // in BG group case allow 1 members group
{
bool leaderChanged = _removeMember(guid);
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index a5e1d3633eb..6bf1a300ac8 100644
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -161,14 +161,14 @@ struct QuestLocale
{
QuestLocale() { ObjectiveText.resize(QUEST_OBJECTIVES_COUNT); }
- std::vector<std::string> Title;
- std::vector<std::string> Details;
- std::vector<std::string> Objectives;
- std::vector<std::string> OfferRewardText;
- std::vector<std::string> RequestItemsText;
- std::vector<std::string> EndText;
- std::vector<std::string> CompletedText;
- std::vector< std::vector<std::string> > ObjectiveText;
+ StringVector Title;
+ StringVector Details;
+ StringVector Objectives;
+ StringVector OfferRewardText;
+ StringVector RequestItemsText;
+ StringVector EndText;
+ StringVector CompletedText;
+ std::vector< StringVector > ObjectiveText;
};
// This Quest class provides a convenient way to access a few pretotaled (cached) quest details,
diff --git a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp
index c67adcdde38..524c05be372 100644
--- a/src/server/game/Server/Protocol/Handlers/LootHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/LootHandler.cpp
@@ -352,7 +352,7 @@ void WorldSession::DoLootRelease(uint64 lguid)
else if (go->GetGoType() == GAMEOBJECT_TYPE_FISHINGHOLE)
{ // The fishing hole used once more
go->AddUse(); // if the max usage is reached, will be despawned in next tick
- if (go->GetUseCount() >= irand(go->GetGOInfo()->fishinghole.minSuccessOpens,go->GetGOInfo()->fishinghole.maxSuccessOpens))
+ if (go->GetUseCount() >= urand(go->GetGOInfo()->fishinghole.minSuccessOpens, go->GetGOInfo()->fishinghole.maxSuccessOpens))
{
go->SetLootState(GO_JUST_DEACTIVATED);
}
diff --git a/src/server/game/Server/Protocol/Handlers/NPCHandler.h b/src/server/game/Server/Protocol/Handlers/NPCHandler.h
index 98e2fd218d3..00edb9abeab 100644
--- a/src/server/game/Server/Protocol/Handlers/NPCHandler.h
+++ b/src/server/game/Server/Protocol/Handlers/NPCHandler.h
@@ -65,15 +65,15 @@ struct GossipText
struct PageTextLocale
{
- std::vector<std::string> Text;
+ StringVector Text;
};
struct NpcTextLocale
{
NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); }
- std::vector<std::vector<std::string> > Text_0;
- std::vector<std::vector<std::string> > Text_1;
+ std::vector<StringVector> Text_0;
+ std::vector<StringVector> Text_1;
};
#endif
diff --git a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
index fa8b11d6429..a0e50487de4 100644
--- a/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
+++ b/src/server/game/Server/Protocol/Handlers/QueryHandler.cpp
@@ -484,7 +484,7 @@ void WorldSession::HandleQuestPOIQuery(WorldPacket& recv_data)
WorldPacket data(SMSG_QUEST_POI_QUERY_RESPONSE, 4+(4+4)*count);
data << uint32(count); // count
- for (int i = 0; i < count; ++i)
+ for (uint32 i = 0; i < count; ++i)
{
uint32 questId;
recv_data >> questId; // quest id
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 7df7350f344..43e1febeaed 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -668,16 +668,16 @@ int32 AuraEffect::CalculateAmount(Unit * caster)
{
if (caster->GetTypeId() == TYPEID_PLAYER)
{
- int32 value = int32((amount*-1)-10);
+ int32 value = (-1 * amount) - 10;
uint32 defva = uint32(caster->ToPlayer()->GetSkillValue(SKILL_DEFENSE) + caster->ToPlayer()->GetRatingBonusValue(CR_DEFENSE_SKILL));
if (defva > 400)
- value += int32((defva-400)*0.15);
+ value += int32((defva - 400) * 0.15);
// Glyph of Icebound Fortitude
- if (AuraEffect const * aurEff = caster->GetAuraEffect(58625,0))
+ if (AuraEffect const * aurEff = caster->GetAuraEffect(58625, 0))
{
- uint32 valMax = aurEff->GetAmount();
+ int32 valMax = aurEff->GetAmount();
if (value < valMax)
value = valMax;
}
@@ -1908,7 +1908,7 @@ void AuraEffect::PeriodicDummyTick(Unit * target, Unit * caster) const
target->CastSpell((Unit*)NULL, m_spellProto->EffectTriggerSpell[m_effIndex], true);
break;
case 62399: // Overload Circuit
- if (target->GetMap()->IsDungeon() && target->GetAppliedAuras().count(62399) >= (target->GetMap()->IsHeroic() ? 4 : 2))
+ if (target->GetMap()->IsDungeon() && int(target->GetAppliedAuras().count(62399)) >= (target->GetMap()->IsHeroic() ? 4 : 2))
{
target->CastSpell(target, 62475, true); // System Shutdown
if (Unit *veh = target->GetVehicleBase())
@@ -5920,7 +5920,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo
{
SpellEntry const * spell = sSpellStore.LookupEntry(spellId);
- for (int i=0; i < spell->StackAmount; ++i)
+ for (uint32 i = 0; i < spell->StackAmount; ++i)
caster->CastSpell(target, spell->Id, true, NULL, NULL, GetCasterGUID());
break;
}
@@ -5934,7 +5934,7 @@ void AuraEffect::HandleAuraDummy(AuraApplication const * aurApp, uint8 mode, boo
if (apply && caster)
{
SpellEntry const * spell = sSpellStore.LookupEntry(spellId);
- for (int i=0; i < spell->StackAmount; ++i)
+ for (uint32 i = 0; i < spell->StackAmount; ++i)
caster->CastSpell(target, spell->Id, true, NULL, NULL, GetCasterGUID());
break;
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 2831bbce8cd..4d0e43fd678 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -603,7 +603,7 @@ void Aura::UpdateOwner(uint32 diff, WorldObject * owner)
Update(diff, caster);
- if (m_updateTargetMapInterval <= diff)
+ if (m_updateTargetMapInterval <= int32(diff))
UpdateTargetMap(caster);
else
m_updateTargetMapInterval -= diff;
@@ -631,7 +631,7 @@ void Aura::Update(uint32 diff, Unit * caster)
// handle manaPerSecond/manaPerSecondPerLevel
if (m_timeCla)
{
- if (m_timeCla > diff)
+ if (m_timeCla > int32(diff))
m_timeCla -= diff;
else if (caster)
{
@@ -642,7 +642,7 @@ void Aura::Update(uint32 diff, Unit * caster)
Powers powertype = Powers(m_spellProto->powerType);
if (powertype == POWER_HEALTH)
{
- if (caster->GetHealth() > manaPerSecond)
+ if (int32(caster->GetHealth()) > manaPerSecond)
caster->ModifyHealth(-manaPerSecond);
else
{
@@ -652,7 +652,7 @@ void Aura::Update(uint32 diff, Unit * caster)
}
else
{
- if (caster->GetPower(powertype) >= manaPerSecond)
+ if (int32(caster->GetPower(powertype)) >= manaPerSecond)
caster->ModifyPower(powertype, -manaPerSecond);
else
{
@@ -730,7 +730,7 @@ bool Aura::ModStackAmount(int32 num)
// Modify stack but limit it
int32 stackAmount = m_stackAmount + num;
- if (stackAmount > m_spellProto->StackAmount)
+ if (stackAmount > int32(m_spellProto->StackAmount))
stackAmount = m_spellProto->StackAmount;
else if (stackAmount <= 0) // Last aura from stack removed
{
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index f8128a632ea..9b53c31b814 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -988,7 +988,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex)
if (m_auraScaleMask && ihit->effectMask == m_auraScaleMask && m_caster != pVictim)
{
SpellEntry const * auraSpell = sSpellStore.LookupEntry(sSpellMgr.GetFirstSpellInChain(m_spellInfo->Id));
- if ((pVictim->getLevel() + 10) >= auraSpell->spellLevel)
+ if (uint32(pVictim->getLevel() + 10) >= auraSpell->spellLevel)
ihit->scaleAura = true;
}
return;
@@ -1009,7 +1009,7 @@ void Spell::AddUnitTarget(Unit* pVictim, uint32 effIndex)
if (m_auraScaleMask && target.effectMask == m_auraScaleMask && m_caster != pVictim)
{
SpellEntry const * auraSpell = sSpellStore.LookupEntry(sSpellMgr.GetFirstSpellInChain(m_spellInfo->Id));
- if ((pVictim->getLevel() + 10) >= auraSpell->spellLevel)
+ if (uint32(pVictim->getLevel() + 10) >= auraSpell->spellLevel)
target.scaleAura = true;
}
@@ -5983,7 +5983,7 @@ SpellCastResult Spell::CheckPower()
// health as power used - need check health amount
if (m_spellInfo->powerType == POWER_HEALTH)
{
- if (m_caster->GetHealth() <= m_powerCost)
+ if (int32(m_caster->GetHealth()) <= m_powerCost)
return SPELL_FAILED_CASTER_AURASTATE;
return SPELL_CAST_OK;
}
@@ -6004,7 +6004,7 @@ SpellCastResult Spell::CheckPower()
// Check power amount
Powers powerType = Powers(m_spellInfo->powerType);
- if (m_caster->GetPower(powerType) < m_powerCost)
+ if (int32(m_caster->GetPower(powerType)) < m_powerCost)
return SPELL_FAILED_NO_POWER;
else
return SPELL_CAST_OK;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 29a51df0caf..7bd4924c8a6 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -552,7 +552,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
if (AuraEffect * aurEff = m_caster->GetDummyAuraEffect(SPELLFAMILY_PRIEST, 2874, 0))
back_damage -= aurEff->GetAmount() * back_damage / 100;
- if (back_damage < unitTarget->GetHealth())
+ if (back_damage < int32(unitTarget->GetHealth()))
m_caster->CastCustomSpell(m_caster, 32409, &back_damage, 0, 0, true);
}
// Mind Blast - applies Mind Trauma if:
@@ -1615,7 +1615,7 @@ void Spell::EffectDummy(uint32 i)
Unit::AttackerSet attackers = unitTarget->getAttackers();
// selected from list 3
- for (int i = 0; i < std::min(size_t(3),attackers.size()); ++i)
+ for (uint32 i = 0; i < std::min(size_t(3), attackers.size()); ++i)
{
Unit::AttackerSet::iterator aItr = attackers.begin();
std::advance(aItr, rand() % attackers.size());
@@ -1968,7 +1968,7 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
if (!spell)
return;
- for (int j=0; j < spell->StackAmount; ++j)
+ for (uint32 j = 0; j < spell->StackAmount; ++j)
m_caster->CastSpell(unitTarget, spell->Id, true);
return;
}
@@ -1980,7 +1980,7 @@ void Spell::EffectTriggerSpell(uint32 effIndex)
if (!spell)
return;
- for (int j=0; j < spell->StackAmount; ++j)
+ for (uint32 j = 0; j < spell->StackAmount; ++j)
m_caster->CastSpell(unitTarget, spell->Id, true);
return;
}
@@ -2421,14 +2421,14 @@ void Spell::EffectPowerBurn(uint32 i)
// burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
if (m_spellInfo->ManaCostPercentage)
{
- uint32 maxdamage = m_caster->GetMaxPower(powertype) * damage * 2 / 100;
+ int32 maxdamage = m_caster->GetMaxPower(powertype) * damage * 2 / 100;
damage = unitTarget->GetMaxPower(powertype) * damage / 100;
if (damage > maxdamage) damage = maxdamage;
}
int32 curPower = int32(unitTarget->GetPower(powertype));
- uint32 power = damage;
+ int32 power = damage;
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
if (powertype == POWER_MANA)
power -= unitTarget->GetSpellCritDamageReduction(power);
@@ -2632,10 +2632,11 @@ void Spell::EffectHealthLeech(uint32 i)
if (m_spellInfo->SpellFamilyFlags[0] & 0x80000)
new_damage = damage;
else
- new_damage = int32(damage*multiplier);
+ new_damage = int32(damage * multiplier);
+
uint32 curHealth = unitTarget->GetHealth();
new_damage = m_caster->SpellNonMeleeDamageLog(unitTarget, m_spellInfo->Id, new_damage);
- if (curHealth < new_damage)
+ if (int32(curHealth) < new_damage)
new_damage = curHealth;
if (m_caster->isAlive())
@@ -3359,7 +3360,7 @@ void Spell::EffectSummonType(uint32 i)
{
float radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
- int32 amount = damage > 0 ? damage : 1;
+ uint32 amount = damage > 0 ? damage : 1;
if (m_spellInfo->Id == 18662) // Curse of Doom
amount = 1;
@@ -7093,7 +7094,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *
//float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
float radius = 5.0f;
- int32 amount = damage > 0 ? damage : 1;
+ uint32 amount = damage > 0 ? damage : 1;
int32 duration = GetSpellDuration(m_spellInfo);
switch (m_spellInfo->Id)
{
diff --git a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp
index 0a7360a46e7..36d8a0d742e 100644
--- a/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp
+++ b/src/server/scripts/Northrend/Nexus/Oculus/instance_oculus.cpp
@@ -47,7 +47,7 @@ public:
uint8 uiPlataformUrom;
- uint8 m_auiEncounter[MAX_ENCOUNTER];
+ uint16 m_auiEncounter[MAX_ENCOUNTER];
std::string str_data;
std::list<uint64> GameObjectList;
diff --git a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp
index cadd3f526a9..1240cf4f20b 100644
--- a/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp
+++ b/src/server/scripts/Northrend/VioletHold/instance_violet_hold.cpp
@@ -155,7 +155,7 @@ public:
uint8 uiDoorIntegrity;
- uint8 m_auiEncounter[MAX_ENCOUNTER];
+ uint16 m_auiEncounter[MAX_ENCOUNTER];
uint8 uiCountErekemGuards;
uint8 uiCountActivationCrystals;
uint8 uiCyanigosaEventPhase;
@@ -652,8 +652,8 @@ public:
if (m_auiEncounter[i] == IN_PROGRESS)
m_auiEncounter[i] = NOT_STARTED;
- uiFirstBoss = data3;
- uiSecondBoss = data4;
+ uiFirstBoss = uint8(data3);
+ uiSecondBoss = uint8(data4);
} else OUT_LOAD_INST_DATA_FAIL;
OUT_LOAD_INST_DATA_COMPLETE;
diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h
index 2c72d8b05a0..5324416c05f 100644
--- a/src/server/shared/Common.h
+++ b/src/server/shared/Common.h
@@ -184,6 +184,8 @@ extern char const* localeNames[MAX_LOCALE];
LocaleConstant GetLocaleByName(const std::string& name);
+typedef std::vector<std::string> StringVector;
+
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
#ifdef max
#undef max