*Cleanup, fix many cases of unoptimized loops, potential crashes, excessively large data types, unnecessary or wrong casts, non-standardized function calls, and so on..

*Proper Maexxna Web Spray locations (old locations sent players flying into the air)

--HG--
branch : trunk
This commit is contained in:
maximius
2009-11-01 17:53:07 -08:00
parent 2b2b2a1d0e
commit b257a28fa9
34 changed files with 1088 additions and 1120 deletions
+6 -6
View File
@@ -444,14 +444,14 @@ CREATE TABLE `character_aura` (
`guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
`caster_guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Full Global Unique Identifier',
`spell` int(11) unsigned NOT NULL default '0',
`effect_mask` int(11) unsigned NOT NULL default '0',
`stackcount` int(11) NOT NULL default '1',
`effect_mask` tinyint(3) unsigned NOT NULL default '0',
`stackcount` tinyint(3) unsigned NOT NULL default '1',
`amount0` int(11) NOT NULL default '0',
`amount1` int(11) NOT NULL default '0',
`amount2` int(11) NOT NULL default '0',
`maxduration` int(11) NOT NULL default '0',
`remaintime` int(11) NOT NULL default '0',
`remaincharges` int(11) NOT NULL default '0',
`remaincharges` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`guid`,`spell`,`effect_mask`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Player System';
@@ -1492,14 +1492,14 @@ CREATE TABLE `pet_aura` (
`guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier',
`caster_guid` bigint(20) unsigned NOT NULL default '0' COMMENT 'Full Global Unique Identifier',
`spell` int(11) unsigned NOT NULL default '0',
`effect_mask` int(11) unsigned NOT NULL default '0',
`stackcount` int(11) NOT NULL default '1',
`effect_mask` tinyint(3) unsigned NOT NULL default '0',
`stackcount` tinyint(3) unsigned NOT NULL default '1',
`amount0` int(11) NOT NULL default '0',
`amount1` int(11) NOT NULL default '0',
`amount2` int(11) NOT NULL default '0',
`maxduration` int(11) NOT NULL default '0',
`remaintime` int(11) NOT NULL default '0',
`remaincharges` int(11) NOT NULL default '0',
`remaincharges` tinyint(3) unsigned NOT NULL default '0',
PRIMARY KEY (`guid`,`spell`,`effect_mask`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Pet System';
+8
View File
@@ -0,0 +1,8 @@
ALTER TABLE `character_aura` MODIFY COLUMN `effect_mask` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
MODIFY COLUMN `stackcount` TINYINT(3) UNSIGNED NOT NULL DEFAULT 1,
MODIFY COLUMN `remaincharges` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `pet_aura` MODIFY COLUMN `effect_mask` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0,
MODIFY COLUMN `stackcount` TINYINT(3) UNSIGNED NOT NULL DEFAULT 1,
MODIFY COLUMN `remaincharges` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0;
+3
View File
@@ -0,0 +1,3 @@
-- the (4) in TINYINT(4) is kind of useless here, but whatever. This column should be unsigned.
ALTER TABLE `exploration_basexp` MODIFY COLUMN `level` TINYINT(4) UNSIGNED NOT NULL DEFAULT 0;
+1 -1
View File
@@ -694,7 +694,7 @@ DROP TABLE IF EXISTS `exploration_basexp`;
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
CREATE TABLE `exploration_basexp` (
`level` tinyint(4) NOT NULL default '0',
`level` tinyint(4) unsigned NOT NULL default '0',
`basexp` mediumint(9) NOT NULL default '0',
PRIMARY KEY (`level`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Exploration System';
@@ -188,7 +188,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
InfernalCleanup();
positions.clear();
for (uint8 i =0; i < 5; ++i)
for (uint8 i = 0; i < 5; ++i)
enfeeble_targets[i] = 0;
for (uint8 i = 0; i < TOTAL_INFERNAL_POINTS; ++i)
@@ -202,8 +202,8 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
Cleave_Timer = 8000;
InfernalTimer = 45000;
InfernalCleanupTimer = 47000;
AxesTargetSwitchTimer = 7500 + rand()%12500;
SunderArmorTimer = 5000 + rand()%5000;
AxesTargetSwitchTimer = urand(7500,20000);
SunderArmorTimer = urand(5000,10000);
phase = 1;
if (pInstance)
@@ -242,21 +242,20 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
void InfernalCleanup()
{
//Infernal Cleanup
for (std::vector<uint64>::iterator itr = infernals.begin(); itr!= infernals.end(); ++itr)
{
Unit *pInfernal = Unit::GetUnit(*m_creature, *itr);
if (pInfernal && pInfernal->isAlive())
{
pInfernal->SetVisibility(VISIBILITY_OFF);
pInfernal->setDeathState(JUST_DIED);
}
}
for (std::vector<uint64>::iterator itr = infernals.begin(); itr != infernals.end(); ++itr)
if (Unit *pInfernal = Unit::GetUnit(*m_creature, *itr))
if (pInfernal->isAlive())
{
pInfernal->SetVisibility(VISIBILITY_OFF);
pInfernal->setDeathState(JUST_DIED);
}
infernals.clear();
}
void AxesCleanup()
{
for (uint8 i=0; i<2; ++i)
for (uint8 i = 0; i < 2; ++i)
{
Unit *axe = Unit::GetUnit(*m_creature, axes[i]);
if (axe && axe->isAlive())
@@ -291,23 +290,18 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
//begin + 1, so we don't target the one with the highest threat
std::list<HostilReference *>::iterator itr = t_list.begin();
std::advance(itr, 1);
for (; itr!= t_list.end(); ++itr) //store the threat list in a different container
{
Unit *pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
//only on alive players
if (pTarget && pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER)
targets.push_back(pTarget);
}
for (; itr != t_list.end(); ++itr) //store the threat list in a different container
if (Unit *pTarget = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid()))
if (pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER)
targets.push_back(pTarget);
//cut down to size if we have more than 5 targets
while(targets.size() > 5)
while (targets.size() > 5)
targets.erase(targets.begin()+rand()%targets.size());
int i = 0;
for (std::vector<Unit *>::iterator iter = targets.begin(); iter!= targets.end(); ++iter, ++i)
{
Unit *pTarget = *iter;
if (pTarget)
uint32 i = 0;
for (std::vector<Unit *>::iterator iter = targets.begin(); iter != targets.end(); ++iter, ++i)
if (Unit *pTarget = *iter)
{
enfeeble_targets[i] = pTarget->GetGUID();
enfeeble_health[i] = pTarget->GetHealth();
@@ -315,8 +309,6 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
pTarget->CastSpell(pTarget, SPELL_ENFEEBLE, true, 0, 0, m_creature->GetGUID());
pTarget->SetHealth(1);
}
}
}
void EnfeebleResetHealth()
@@ -367,17 +359,16 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
if (!UpdateVictim())
return;
if (EnfeebleResetTimer)
if (EnfeebleResetTimer <= diff) //Let's not forget to reset that
if (EnfeebleResetTimer && EnfeebleResetTimer <= diff) // Let's not forget to reset that
{
EnfeebleResetHealth();
EnfeebleResetTimer=0;
EnfeebleResetTimer = 0;
} else EnfeebleResetTimer -= diff;
if (m_creature->hasUnitState(UNIT_STAT_STUNNED)) //While shifting to phase 2 malchezaar stuns himself
if (m_creature->hasUnitState(UNIT_STAT_STUNNED)) // While shifting to phase 2 malchezaar stuns himself
return;
if (m_creature->GetUInt64Value(UNIT_FIELD_TARGET)!=m_creature->getVictim()->GetGUID())
if (m_creature->GetUInt64Value(UNIT_FIELD_TARGET) != m_creature->getVictim()->GetGUID())
m_creature->SetUInt64Value(UNIT_FIELD_TARGET, m_creature->getVictim()->GetGUID());
if (phase == 1)
@@ -481,11 +472,10 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
{
if (Unit *axe = Unit::GetUnit(*m_creature, axes[i]))
{
float threat = 1000000.0f;
if (axe->getVictim())
DoModifyThreatPercent(axe->getVictim(), -100);
if (pTarget)
axe->AddThreat(pTarget, threat);
axe->AddThreat(pTarget, 1000000.0f);
//axe->getThreatManager().tauntFadeOut(axe->getVictim());
//axe->getThreatManager().tauntApply(pTarget);
}
@@ -505,13 +495,13 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
if (InfernalTimer <= diff)
{
SummonInfernal(diff);
InfernalTimer = phase == 3 ? 14500 : 44500; //15 secs in phase 3, 45 otherwise
InfernalTimer = phase == 3 ? 14500 : 44500; // 15 secs in phase 3, 45 otherwise
} else InfernalTimer -= diff;
if (ShadowNovaTimer <= diff)
{
DoCast(m_creature->getVictim(), SPELL_SHADOWNOVA);
ShadowNovaTimer = phase == 3 ? 31000 : 4294967295;
ShadowNovaTimer = phase == 3 ? 31000 : uint32(-1);
} else ShadowNovaTimer -= diff;
if (phase != 2)
@@ -521,7 +511,7 @@ struct TRINITY_DLL_DECL boss_malchezaarAI : public ScriptedAI
Unit *pTarget = NULL;
if (phase == 1)
pTarget = m_creature->getVictim(); // the tank
else // anyone but the tank
else // anyone but the tank
pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true);
if (pTarget)
@@ -125,7 +125,8 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI
void UpdateAI(const uint32 diff)
{
//Return since we have no target
if (!UpdateVictim()) return;
if (!UpdateVictim())
return;
if (spawntimer <= diff)
{
@@ -136,20 +137,20 @@ struct MANGOS_DLL_DECL boss_amanitarAI : public ScriptedAI
if (roottimer <= diff)
{
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
m_creature->CastSpell(pTarget, SPELL_ENTANGLING_ROOTS, false);
DoCast(pTarget, SPELL_ENTANGLING_ROOTS);
roottimer = urand(15000,30000);
}
if (bashtimer <= diff)
{
m_creature->CastSpell(m_creature->getVictim(), SPELL_BASH, false);
DoCastVictim(SPELL_BASH);
bashtimer = urand(15000,30000);
} else bashtimer -= diff;
if (bolttimer <= diff)
{
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
m_creature->CastSpell(pTarget, SPELL_VENOM_BOLT_VOLLEY, false);
DoCast(pTarget, SPELL_VENOM_BOLT_VOLLEY);
bolttimer = urand(15000,30000);
} else bolttimer -= diff;
@@ -169,9 +170,10 @@ struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI
void Reset()
{
m_creature->CastSpell(m_creature, SPELL_PUTRID_MUSHROOM, true); // Hack, to make the mushrooms visible, can't find orig. spell...
DoCast(m_creature, SPELL_PUTRID_MUSHROOM, true); // Hack, to make the mushrooms visible, can't find orig. spell...
if (m_creature->GetEntry() == NPC_POISONOUS_MUSHROOM) m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AURA, true);
if (m_creature->GetEntry() == NPC_POISONOUS_MUSHROOM)
DoCast(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AURA, true);
auratimer = 0;
deathtimer = 30000;
@@ -198,8 +200,8 @@ struct MANGOS_DLL_DECL mob_amanitar_mushroomsAI : public Scripted_NoMovementAI
{
if (auratimer <= diff)
{
m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AREA, true);
m_creature->CastSpell(m_creature, POISONOUS_MUSHROOM_SPELL_POISON_CLOUD, false);
DoCast(m_creature, POISONOUS_MUSHROOM_SPELL_VISUAL_AREA, true);
DoCast(m_creature, POISONOUS_MUSHROOM_SPELL_POISON_CLOUD, false);
auratimer = 7000;
} else auratimer -= diff;
}
@@ -31,9 +31,9 @@
#define MAX_POS_WRAP 3
const float PosWrap[MAX_POS_WRAP][3] =
{
{3546.796, -3869.082, 296.450+20},
{3531.271, -3847.424, 299.450+20},
{3497.067, -3843.384, 302.384+20},
{3546.796, -3869.082, 296.450},
{3531.271, -3847.424, 299.450},
{3497.067, -3843.384, 302.384},
};
enum Events
@@ -74,12 +74,12 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI
switch(eventId)
{
case EVENT_WRAP:
for (uint32 i = 0; i < HEROIC(1,2); ++i)
for (uint8 i = 0; i < HEROIC(1,2); ++i)
{
if (Unit *pTarget = SelectTarget(SELECT_TARGET_RANDOM, 1, 0, true, -SPELL_WEB_WRAP))
{
pTarget->RemoveAura(SPELL_WEB_SPRAY);
uint32 pos = rand()%MAX_POS_WRAP;
uint8 pos = rand()%MAX_POS_WRAP;
pTarget->GetMotionMaster()->MoveJump(PosWrap[pos][0], PosWrap[pos][1], PosWrap[pos][2], 20, 20);
if (Creature *wrap = DoSummon(MOB_WEB_WRAP, pTarget, 0, 60000))
{
@@ -104,8 +104,8 @@ struct TRINITY_DLL_DECL boss_maexxnaAI : public BossAI
return;
case EVENT_SUMMON:
{
uint32 amount = 8+rand()%2;
for (uint32 i = 0; i < amount; ++i)
uint8 amount = urand(8,10);
for (uint8 i = 0; i < amount; ++i)
DoSummon(MOB_SPIDERLING, me);
events.ScheduleEvent(EVENT_SUMMON, 40000);
break;
@@ -195,7 +195,7 @@ int32 DoHighUnlearnCost(Player* pPlayer) //tailor, alchemy
int32 DoMedUnlearnCost(Player* pPlayer) //blacksmith, leatherwork
{
uint32 level = pPlayer->getLevel();
uint8 level = pPlayer->getLevel();
if (level < 51)
return 250000;
else if (level < 66)
@@ -206,7 +206,7 @@ int32 DoMedUnlearnCost(Player* pPlayer) //blacksmith, leath
int32 DoLowUnlearnCost(Player* pPlayer) //blacksmith
{
uint32 level = pPlayer->getLevel();
uint8 level = pPlayer->getLevel();
if (level < 66)
return 50000;
else
@@ -224,14 +224,14 @@ bool EquippedOk(Player* pPlayer, uint32 spellId)
if (!spell)
return false;
for (uint8 i=0; i<3; ++i)
for (uint8 i = 0; i < 3; ++i)
{
uint32 reqSpell = spell->EffectTriggerSpell[i];
if (!reqSpell)
continue;
Item* pItem;
for (uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; j++)
for (uint8 j = EQUIPMENT_SLOT_START; j < EQUIPMENT_SLOT_END; ++j)
{
pItem = pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, j);
if (pItem)
+1 -1
View File
@@ -593,7 +593,7 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player,
}
void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player,
std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
std::wstring const& wsearchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint32 usable,
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
uint32& count, uint32& totalcount)
{
+1 -1
View File
@@ -108,7 +108,7 @@ class AuctionHouseObject
void BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
void BuildListOwnerItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount);
void BuildListAuctionItems(WorldPacket& data, Player* player,
std::wstring const& searchedname, uint32 listfrom, uint32 levelmin, uint32 levelmax, uint32 usable,
std::wstring const& searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint32 usable,
uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality,
uint32& count, uint32& totalcount);
+17 -17
View File
@@ -247,38 +247,38 @@ void BattleGroundAV::UpdateScore(uint16 team, int16 points )
}
}
Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type )
Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type)
{
uint32 level;
bool isStatic=false;
uint8 level;
bool isStatic = false;
Creature* creature = NULL;
assert(type <= AV_CPLACE_MAX + AV_STATICCPLACE_MAX);
if(type>=AV_CPLACE_MAX) //static
if (type >= AV_CPLACE_MAX) //static
{
type-=AV_CPLACE_MAX;
cinfoid=int(BG_AV_StaticCreaturePos[type][4]);
type -= AV_CPLACE_MAX;
cinfoid=uint16(BG_AV_StaticCreaturePos[type][4]);
creature = AddCreature(BG_AV_StaticCreatureInfo[cinfoid][0],(type+AV_CPLACE_MAX),BG_AV_StaticCreatureInfo[cinfoid][1],BG_AV_StaticCreaturePos[type][0],BG_AV_StaticCreaturePos[type][1],BG_AV_StaticCreaturePos[type][2],BG_AV_StaticCreaturePos[type][3]);
level = ( BG_AV_StaticCreatureInfo[cinfoid][2] == BG_AV_StaticCreatureInfo[cinfoid][3] ) ? BG_AV_StaticCreatureInfo[cinfoid][2] : urand(BG_AV_StaticCreatureInfo[cinfoid][2],BG_AV_StaticCreatureInfo[cinfoid][3]);
isStatic=true;
level = (BG_AV_StaticCreatureInfo[cinfoid][2] == BG_AV_StaticCreatureInfo[cinfoid][3]) ? BG_AV_StaticCreatureInfo[cinfoid][2] : urand(BG_AV_StaticCreatureInfo[cinfoid][2],BG_AV_StaticCreatureInfo[cinfoid][3]);
isStatic = true;
}
else
{
creature = AddCreature(BG_AV_CreatureInfo[cinfoid][0],type,BG_AV_CreatureInfo[cinfoid][1],BG_AV_CreaturePos[type][0],BG_AV_CreaturePos[type][1],BG_AV_CreaturePos[type][2],BG_AV_CreaturePos[type][3]);
level = ( BG_AV_CreatureInfo[cinfoid][2] == BG_AV_CreatureInfo[cinfoid][3] ) ? BG_AV_CreatureInfo[cinfoid][2] : urand(BG_AV_CreatureInfo[cinfoid][2],BG_AV_CreatureInfo[cinfoid][3]);
level = (BG_AV_CreatureInfo[cinfoid][2] == BG_AV_CreatureInfo[cinfoid][3]) ? BG_AV_CreatureInfo[cinfoid][2] : urand(BG_AV_CreatureInfo[cinfoid][2],BG_AV_CreatureInfo[cinfoid][3]);
}
if(!creature)
if (!creature)
return NULL;
if(creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0] || creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0])
if (creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_A_CAPTAIN][0] || creature->GetEntry() == BG_AV_CreatureInfo[AV_NPC_H_CAPTAIN][0])
creature->SetRespawnDelay(RESPAWN_ONE_DAY); // TODO: look if this can be done by database + also add this for the wingcommanders
if((isStatic && cinfoid>=10 && cinfoid<=14) || (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3) ||
(cinfoid>=AV_NPC_H_GRAVEDEFENSE0 && cinfoid<=AV_NPC_H_GRAVEDEFENSE3))))
if ((isStatic && cinfoid>=10 && cinfoid<=14) || (!isStatic && ((cinfoid >= AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3) ||
(cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3))))
{
if(!isStatic && ((cinfoid>=AV_NPC_A_GRAVEDEFENSE0 && cinfoid<=AV_NPC_A_GRAVEDEFENSE3)
|| (cinfoid>=AV_NPC_H_GRAVEDEFENSE0 && cinfoid<=AV_NPC_H_GRAVEDEFENSE3)))
|| (cinfoid >= AV_NPC_H_GRAVEDEFENSE0 && cinfoid <= AV_NPC_H_GRAVEDEFENSE3)))
{
CreatureData &data = objmgr.NewOrExistCreatureData(creature->GetDBTableGUIDLow());
data.spawndist = 5;
data.spawndist = 5;
}
//else spawndist will be 15, so creatures move maximum=10
//creature->SetDefaultMovementType(RANDOM_MOTION_TYPE);
@@ -289,8 +289,8 @@ Creature* BattleGroundAV::AddAVCreature(uint16 cinfoid, uint16 type )
//just copied this code from a gm-command
}
if(level != 0)
level += m_MaxLevel-60; //maybe we can do this more generic for custom level-range.. actually it's blizzlike
if (level != 0)
level += m_MaxLevel - 60; //maybe we can do this more generic for custom level-range.. actually it's blizzlike
creature->SetLevel(level);
return creature;
}
+5 -5
View File
@@ -1390,9 +1390,9 @@ void Creature::SelectLevel(const CreatureInfo *cinfo)
uint32 rank = isPet()? 0 : cinfo->rank;
// level
uint32 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel);
uint32 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel);
uint32 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel);
uint8 minlevel = std::min(cinfo->maxlevel, cinfo->minlevel);
uint8 maxlevel = std::max(cinfo->maxlevel, cinfo->minlevel);
uint8 level = minlevel == maxlevel ? minlevel : urand(minlevel, maxlevel);
SetLevel(level);
float rellevel = maxlevel == minlevel ? 0 : (float(level - minlevel))/(maxlevel - minlevel);
@@ -2510,12 +2510,12 @@ void Creature::AllLootRemovedFromCorpse()
}
}
uint32 Creature::getLevelForTarget( Unit const* target ) const
uint8 Creature::getLevelForTarget(Unit const* target) const
{
if(!isWorldBoss())
return Unit::getLevelForTarget(target);
uint32 level = target->getLevel()+sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF);
uint16 level = target->getLevel()+sWorld.getConfig(CONFIG_WORLD_BOSS_LEVEL_DIFF);
if(level < 1)
return 1;
if(level > 255)
+1 -1
View File
@@ -530,7 +530,7 @@ class TRINITY_DLL_SPEC Creature : public Unit
return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
}
uint32 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
uint8 getLevelForTarget(Unit const* target) const; // overwrite Unit::getLevelForTarget for boss level support
bool IsInEvadeMode() const { return hasUnitState(UNIT_STAT_EVADE); }
+52 -54
View File
@@ -29,14 +29,14 @@ template<class T>
inline
const T& RAND(const T& v1, const T& v2)
{
return (rand()%2) ? v1 : v2;
return (urand(0,1)) ? v1 : v2;
}
template<class T>
inline
const T& RAND(const T& v1, const T& v2, const T& v3)
{
switch(rand()%3)
switch (urand(0,2))
{
default:
case 0: return v1;
@@ -49,7 +49,7 @@ template<class T>
inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4)
{
switch(rand()%4)
switch (urand(0,3))
{
default:
case 0: return v1;
@@ -63,7 +63,7 @@ template<class T>
inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5)
{
switch(rand()%5)
switch (urand(0,4))
{
default:
case 0: return v1;
@@ -78,7 +78,7 @@ template<class T>
inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6)
{
switch(rand()%6)
switch (urand(0,5))
{
default:
case 0: return v1;
@@ -94,7 +94,7 @@ template<class T>
inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7)
{
switch(rand()%7)
switch (urand(0,6))
{
default:
case 0: return v1;
@@ -111,7 +111,7 @@ template<class T>
inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8)
{
switch(rand()%8)
switch (urand(0,7))
{
default:
case 0: return v1;
@@ -130,7 +130,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9)
{
switch(rand()%9)
switch (urand(0,8))
{
default:
case 0: return v1;
@@ -150,7 +150,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10)
{
switch(rand()%10)
switch (urand(0,9))
{
default:
case 0: return v1;
@@ -171,7 +171,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10, const T& v11)
{
switch(rand()%11)
switch (urand(0,10))
{
default:
case 0: return v1;
@@ -193,7 +193,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10, const T& v11, const T& v12)
{
switch(rand()%12)
switch (urand(0,11))
{
default:
case 0: return v1;
@@ -216,7 +216,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13)
{
switch(rand()%13)
switch (urand(0,12))
{
default:
case 0: return v1;
@@ -240,7 +240,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14)
{
switch(rand()%14)
switch (urand(0,13))
{
default:
case 0: return v1;
@@ -265,7 +265,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15)
{
switch(rand()%15)
switch (urand(0,14))
{
default:
case 0: return v1;
@@ -291,7 +291,7 @@ inline
const T& RAND(const T& v1, const T& v2, const T& v3, const T& v4, const T& v5, const T& v6, const T& v7, const T& v8,
const T& v9, const T& v10, const T& v11, const T& v12, const T& v13, const T& v14, const T& v15, const T& v16)
{
switch(rand()%16)
switch (urand(0,15))
{
default:
case 0: return v1;
@@ -328,19 +328,19 @@ class EventMap : private std::map<uint32, uint32>
void SetPhase(uint32 phase)
{
if(phase && phase < 9)
if (phase && phase < 9)
m_phase = (1 << (phase + 24));
}
void ScheduleEvent(uint32 eventId, uint32 time, uint32 gcd = 0, uint32 phase = 0)
{
time += m_time;
if(gcd && gcd < 9)
if (gcd && gcd < 9)
eventId |= (1 << (gcd + 16));
if(phase && phase < 9)
if (phase && phase < 9)
eventId |= (1 << (phase + 24));
iterator itr = find(time);
while(itr != end())
while (itr != end())
{
++time;
itr = find(time);
@@ -356,13 +356,13 @@ class EventMap : private std::map<uint32, uint32>
void RepeatEvent(uint32 time)
{
if(empty())
if (empty())
return;
uint32 eventId = begin()->second;
erase(begin());
time += m_time;
iterator itr = find(time);
while(itr != end())
while (itr != end())
{
++time;
itr = find(time);
@@ -377,11 +377,11 @@ class EventMap : private std::map<uint32, uint32>
uint32 ExecuteEvent()
{
while(!empty())
while (!empty())
{
if(begin()->first > m_time)
if (begin()->first > m_time)
return 0;
else if(m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
erase(begin());
else
{
@@ -395,16 +395,14 @@ class EventMap : private std::map<uint32, uint32>
uint32 GetEvent()
{
while(!empty())
while (!empty())
{
if(begin()->first > m_time)
if (begin()->first > m_time)
return 0;
else if(m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
else if (m_phase && (begin()->second & 0xFF000000) && !(begin()->second & m_phase))
erase(begin());
else
{
return (begin()->second & 0x0000FFFF);
}
}
return 0;
}
@@ -413,11 +411,11 @@ class EventMap : private std::map<uint32, uint32>
{
time += m_time;
gcd = (1 << (gcd + 16));
for (iterator itr = begin(); itr != end(); )
for (iterator itr = begin(); itr != end();)
{
if(itr->first >= time)
if (itr->first >= time)
break;
if(itr->second & gcd)
if (itr->second & gcd)
{
ScheduleEvent(time, itr->second);
erase(itr++);
@@ -429,9 +427,9 @@ class EventMap : private std::map<uint32, uint32>
void CancelEvent(uint32 eventId)
{
for (iterator itr = begin(); itr != end(); )
for (iterator itr = begin(); itr != end();)
{
if(eventId == (itr->second & 0x0000FFFF))
if (eventId == (itr->second & 0x0000FFFF))
erase(itr++);
else
++itr;
@@ -440,9 +438,9 @@ class EventMap : private std::map<uint32, uint32>
void CancelEventsByGCD(uint32 gcd)
{
for (iterator itr = begin(); itr != end(); )
for (iterator itr = begin(); itr != end();)
{
if(itr->second & gcd)
if (itr->second & gcd)
erase(itr++);
else
++itr;
@@ -484,7 +482,7 @@ TRINITY_DLL_SPEC AISpellInfoType * GetAISpellInfo(uint32 i);
inline void CreatureAI::SetGazeOn(Unit *target)
{
if(me->canAttack(target))
if (me->canAttack(target))
{
AttackStart(target);
me->SetReactState(REACT_PASSIVE);
@@ -493,34 +491,34 @@ inline void CreatureAI::SetGazeOn(Unit *target)
inline bool CreatureAI::UpdateVictimWithGaze()
{
if(!me->isInCombat())
if (!me->isInCombat())
return false;
if(me->HasReactState(REACT_PASSIVE))
if (me->HasReactState(REACT_PASSIVE))
{
if(me->getVictim())
if (me->getVictim())
return true;
else
me->SetReactState(REACT_AGGRESSIVE);
}
if(Unit *victim = me->SelectVictim())
if (Unit *victim = me->SelectVictim())
AttackStart(victim);
return me->getVictim();
}
inline bool CreatureAI::UpdateCombatState()
{
if(!me->isInCombat())
if (!me->isInCombat())
return false;
if(!me->HasReactState(REACT_PASSIVE))
if (!me->HasReactState(REACT_PASSIVE))
{
if(Unit *victim = me->SelectVictim())
if (Unit *victim = me->SelectVictim())
AttackStart(victim);
return me->getVictim();
}
else if(me->getThreatManager().isThreatListEmpty())
else if (me->getThreatManager().isThreatListEmpty())
{
EnterEvadeMode();
return false;
@@ -531,16 +529,16 @@ inline bool CreatureAI::UpdateCombatState()
inline bool CreatureAI::UpdateVictim()
{
if(!me->isInCombat())
if (!me->isInCombat())
return false;
if(!me->HasReactState(REACT_PASSIVE))
if (!me->HasReactState(REACT_PASSIVE))
{
if(Unit *victim = me->SelectVictim())
AttackStart(victim);
return me->getVictim();
}
else if(me->getThreatManager().isThreatListEmpty())
else if (me->getThreatManager().isThreatListEmpty())
{
EnterEvadeMode();
return false;
@@ -552,9 +550,9 @@ inline bool CreatureAI::UpdateVictim()
/*
inline bool CreatureAI::UpdateVictim()
{
if(!me->isInCombat())
if (!me->isInCombat())
return false;
if(Unit *victim = me->SelectVictim())
if (Unit *victim = me->SelectVictim())
AttackStart(victim);
return me->getVictim();
}
@@ -562,7 +560,7 @@ inline bool CreatureAI::UpdateVictim()
inline bool CreatureAI::_EnterEvadeMode()
{
if(!me->isAlive())
if (!me->isAlive())
return false;
// sometimes bosses stuck in combat?
@@ -573,7 +571,7 @@ inline bool CreatureAI::_EnterEvadeMode()
me->SetLootRecipient(NULL);
me->ResetPlayerDamageReq();
if(me->IsInEvadeMode())
if (me->IsInEvadeMode())
return false;
return true;
@@ -581,7 +579,7 @@ inline bool CreatureAI::_EnterEvadeMode()
inline void UnitAI::DoCast(Unit* victim, uint32 spellId, bool triggered)
{
if(!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered))
if (!victim || (me->hasUnitState(UNIT_STAT_CASTING) && !triggered))
return;
me->CastSpell(victim, spellId, triggered);
@@ -594,7 +592,7 @@ inline void UnitAI::DoCastVictim(uint32 spellId, bool triggered)
inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
{
if(!triggered && me->hasUnitState(UNIT_STAT_CASTING))
if (!triggered && me->hasUnitState(UNIT_STAT_CASTING))
return;
me->CastSpell((Unit*)NULL, spellId, triggered);
+37 -37
View File
@@ -27,61 +27,61 @@ namespace Trinity
{
namespace Honor
{
inline uint32 hk_honor_at_level(uint32 level, uint32 count=1)
inline uint32 hk_honor_at_level(uint8 level, uint32 count = 1)
{
return (uint32)ceil(count*(-0.53177f + 0.59357f * exp((level +23.54042f) / 26.07859f )));
return uint32(ceil(count*(-0.53177f + 0.59357f * exp((level + 23.54042f) / 26.07859f))));
}
}
namespace XP
{
enum XPColorChar { RED, ORANGE, YELLOW, GREEN, GRAY };
inline uint32 GetGrayLevel(uint32 pl_level)
inline uint8 GetGrayLevel(uint8 pl_level)
{
if( pl_level <= 5 )
if (pl_level <= 5)
return 0;
else if( pl_level <= 39 )
else if (pl_level <= 39)
return pl_level - 5 - pl_level/10;
else if( pl_level <= 59 )
else if (pl_level <= 59)
return pl_level - 1 - pl_level/5;
else
return pl_level - 9;
}
inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level)
inline XPColorChar GetColorCode(uint8 pl_level, uint8 mob_level)
{
if( mob_level >= pl_level + 5 )
if (mob_level >= pl_level + 5)
return RED;
else if( mob_level >= pl_level + 3 )
else if (mob_level >= pl_level + 3)
return ORANGE;
else if( mob_level >= pl_level - 2 )
else if (mob_level >= pl_level - 2)
return YELLOW;
else if( mob_level > GetGrayLevel(pl_level) )
else if (mob_level > GetGrayLevel(pl_level))
return GREEN;
else
return GRAY;
}
inline uint32 GetZeroDifference(uint32 pl_level)
inline uint8 GetZeroDifference(uint8 pl_level)
{
if( pl_level < 8 ) return 5;
if( pl_level < 10 ) return 6;
if( pl_level < 12 ) return 7;
if( pl_level < 16 ) return 8;
if( pl_level < 20 ) return 9;
if( pl_level < 30 ) return 11;
if( pl_level < 40 ) return 12;
if( pl_level < 45 ) return 13;
if( pl_level < 50 ) return 14;
if( pl_level < 55 ) return 15;
if( pl_level < 60 ) return 16;
if (pl_level < 8) return 5;
if (pl_level < 10) return 6;
if (pl_level < 12) return 7;
if (pl_level < 16) return 8;
if (pl_level < 20) return 9;
if (pl_level < 30) return 11;
if (pl_level < 40) return 12;
if (pl_level < 45) return 13;
if (pl_level < 50) return 14;
if (pl_level < 55) return 15;
if (pl_level < 60) return 16;
return 17;
}
inline uint32 BaseGain(uint32 pl_level, uint32 mob_level, ContentLevels content)
inline uint32 BaseGain(uint8 pl_level, uint8 mob_level, ContentLevels content)
{
uint32 nBaseExp;
switch(content)
switch (content)
{
case CONTENT_1_60: nBaseExp = 45; break;
case CONTENT_61_70: nBaseExp = 235; break;
@@ -91,19 +91,19 @@ namespace Trinity
nBaseExp = 45; break;
}
if( mob_level >= pl_level )
if (mob_level >= pl_level)
{
uint32 nLevelDiff = mob_level - pl_level;
uint8 nLevelDiff = mob_level - pl_level;
if (nLevelDiff > 4)
nLevelDiff = 4;
return ((pl_level*5 + nBaseExp) * (20 + nLevelDiff)/10 + 1)/2;
}
else
{
uint32 gray_level = GetGrayLevel(pl_level);
if( mob_level > gray_level )
uint8 gray_level = GetGrayLevel(pl_level);
if (mob_level > gray_level)
{
uint32 ZD = GetZeroDifference(pl_level);
uint8 ZD = GetZeroDifference(pl_level);
return (pl_level*5 + nBaseExp) * (ZD + mob_level - pl_level)/ZD;
}
return 0;
@@ -112,31 +112,31 @@ namespace Trinity
inline uint32 Gain(Player *pl, Unit *u)
{
if(u->GetTypeId()==TYPEID_UNIT && (
if (u->GetTypeId()==TYPEID_UNIT && (
((Creature*)u)->isTotem() || ((Creature*)u)->isPet() ||
(((Creature*)u)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) ))
return 0;
uint32 xp_gain= BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId()));
if( xp_gain == 0 )
uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(u->GetMapId(),u->GetZoneId()));
if (xp_gain == 0)
return 0;
if(u->GetTypeId()==TYPEID_UNIT && ((Creature*)u)->isElite())
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->isElite())
xp_gain *= 2;
return (uint32)(xp_gain*sWorld.getRate(RATE_XP_KILL));
return uint32(xp_gain*sWorld.getRate(RATE_XP_KILL));
}
inline float xp_in_group_rate(uint32 count, bool isRaid)
{
if(isRaid)
if (isRaid)
{
// FIX ME: must apply decrease modifiers dependent from raid size
return 1.0f;
}
else
{
switch(count)
switch (count)
{
case 0:
case 1:
+21 -26
View File
@@ -1291,12 +1291,12 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_FLAGSTAND: // 24
{
if(user->GetTypeId() != TYPEID_PLAYER)
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if( player->CanUseBattleGroundObject() )
if (player->CanUseBattleGroundObject())
{
// in battleground check
BattleGround *bg = player->GetBattleGround();
@@ -1316,16 +1316,16 @@ void GameObject::Use(Unit* user)
}
case GAMEOBJECT_TYPE_FLAGDROP: // 26
{
if(user->GetTypeId() != TYPEID_PLAYER)
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
if( player->CanUseBattleGroundObject() )
if (player->CanUseBattleGroundObject())
{
// in battleground check
BattleGround *bg = player->GetBattleGround();
if(!bg)
if (!bg)
return;
// BG flag dropped
// WS:
@@ -1334,7 +1334,7 @@ void GameObject::Use(Unit* user)
// EotS:
// 184142 - Netherstorm Flag
GameObjectInfo const* info = GetGOInfo();
if(info)
if (info)
{
switch(info->id)
{
@@ -1362,10 +1362,10 @@ void GameObject::Use(Unit* user)
case GAMEOBJECT_TYPE_BARBER_CHAIR: //32
{
GameObjectInfo const* info = GetGOInfo();
if(!info)
if (!info)
return;
if(user->GetTypeId() != TYPEID_PLAYER)
if (user->GetTypeId() != TYPEID_PLAYER)
return;
Player* player = (Player*)user;
@@ -1384,11 +1384,11 @@ void GameObject::Use(Unit* user)
break;
}
if(!spellId)
if (!spellId)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry( spellId );
if(!spellInfo)
if (!spellInfo)
{
if(user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr.HandleCustomSpell((Player*)user,spellId,this))
sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u )", spellId,GetEntry(),GetGoType());
@@ -1402,7 +1402,7 @@ void GameObject::Use(Unit* user)
// spell target is user of GO
SpellCastTargets targets;
targets.setUnitTarget( user );
targets.setUnitTarget(user);
spell->prepare(&targets);
}
@@ -1410,7 +1410,7 @@ void GameObject::Use(Unit* user)
void GameObject::CastSpell(Unit* target, uint32 spellId)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
if(!spellInfo)
if (!spellInfo)
return;
bool self = false;
@@ -1462,7 +1462,7 @@ void GameObject::SendCustomAnim()
bool GameObject::IsInRange(float x, float y, float z, float radius) const
{
GameObjectDisplayInfoEntry const * info = sGameObjectDisplayInfoStore.LookupEntry(GetUInt32Value(GAMEOBJECT_DISPLAYID));
if(!info)
if (!info)
return IsWithinDist3d(x, y, z, radius);
float sinA = sin(GetOrientation());
@@ -1482,15 +1482,15 @@ bool GameObject::IsInRange(float x, float y, float z, float radius) const
void GameObject::TakenDamage(uint32 damage)
{
if(!m_goValue->building.health)
if (!m_goValue->building.health)
return;
if(m_goValue->building.health > damage)
if (m_goValue->building.health > damage)
m_goValue->building.health -= damage;
else
m_goValue->building.health = 0;
if(HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed
if (HasFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED)) // from damaged to destroyed
{
if(!m_goValue->building.health)
{
@@ -1503,11 +1503,11 @@ void GameObject::TakenDamage(uint32 damage)
}
else // from intact to damaged
{
if(m_goValue->building.health <= m_goInfo->building.damagedNumHits)
if (m_goValue->building.health <= m_goInfo->building.damagedNumHits)
{
if(!m_goInfo->building.destroyedDisplayId)
if (!m_goInfo->building.destroyedDisplayId)
m_goValue->building.health = 0;
else if(!m_goValue->building.health)
else if (!m_goValue->building.health)
m_goValue->building.health = 1;
SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED);
@@ -1535,14 +1535,9 @@ void GameObject::EventInform(uint32 eventId)
const char* GameObject::GetNameForLocaleIdx(int32 loc_idx) const
{
if (loc_idx >= 0)
{
GameObjectLocale const *cl = objmgr.GetGameObjectLocale(GetEntry());
if (cl)
{
if (GameObjectLocale const *cl = objmgr.GetGameObjectLocale(GetEntry()))
if (cl->Name.size() > loc_idx && !cl->Name[loc_idx].empty())
return cl->Name[loc_idx].c_str();
}
}
return GetName();
}
@@ -1567,7 +1562,7 @@ void GameObject::UpdateRotationFields(float rotation2 /*=0.0f*/, float rotation3
m_rotation = rotation;
if(rotation2==0.0f && rotation3==0.0f)
if(rotation2 == 0.0f && rotation3 == 0.0f)
{
rotation2 = f_rot1;
rotation3 = f_rot2;
+2 -2
View File
@@ -100,7 +100,7 @@ struct GameObjectInfo
uint32 eventId; //6 lootedEvent
uint32 linkedTrapId; //7
uint32 questId; //8 not used currently but store quest required for GO activation for player
uint32 level; //9
uint8 level; //9
uint32 losOK; //10
uint32 leaveLoot; //11
uint32 notInCombat; //12
@@ -124,7 +124,7 @@ struct GameObjectInfo
struct
{
uint32 lockId; //0 -> Lock.dbc
uint32 level; //1
uint8 level; //1
uint32 radius; //2 radius for trap activation
uint32 spellId; //3
uint32 charges; //4 need respawn (if > 0)
+40 -41
View File
@@ -29,7 +29,7 @@
void InstanceData::SaveToDB()
{
std::string data = GetSaveData();
if(data.empty())
if (data.empty())
return;
CharacterDatabase.escape_string(data);
CharacterDatabase.PExecute("UPDATE instance SET data = '%s' WHERE id = '%d'", data.c_str(), instance->GetInstanceId());
@@ -37,9 +37,9 @@ void InstanceData::SaveToDB()
void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go)
{
if(!go)
if (!go)
go = instance->GetGameObject(GUID);
if(go)
if (go)
go->SetGoState(open ? GO_STATE_ACTIVE : GO_STATE_READY);
else
debug_log("TSCR: InstanceData: HandleGameObject failed");
@@ -48,7 +48,7 @@ void InstanceData::HandleGameObject(uint64 GUID, bool open, GameObject *go)
bool InstanceData::IsEncounterInProgress() const
{
for (std::vector<BossInfo>::const_iterator itr = bosses.begin(); itr != bosses.end(); ++itr)
if(itr->state == IN_PROGRESS)
if (itr->state == IN_PROGRESS)
return true;
return false;
@@ -58,7 +58,7 @@ void InstanceData::LoadMinionData(const MinionData *data)
{
while(data->entry)
{
if(data->bossId < bosses.size())
if (data->bossId < bosses.size())
minions.insert(std::make_pair(data->entry, MinionInfo(&bosses[data->bossId])));
++data;
@@ -70,7 +70,7 @@ void InstanceData::LoadDoorData(const DoorData *data)
{
while(data->entry)
{
if(data->bossId < bosses.size())
if (data->bossId < bosses.size())
doors.insert(std::make_pair(data->entry, DoorInfo(&bosses[data->bossId], data->type, BoundaryType(data->boundary))));
++data;
@@ -80,18 +80,18 @@ void InstanceData::LoadDoorData(const DoorData *data)
void InstanceData::UpdateMinionState(Creature *minion, EncounterState state)
{
switch(state)
switch (state)
{
case NOT_STARTED:
if(!minion->isAlive())
if (!minion->isAlive())
minion->Respawn();
else if(minion->isInCombat())
else if (minion->isInCombat())
minion->AI()->EnterEvadeMode();
break;
case IN_PROGRESS:
if(!minion->isAlive())
if (!minion->isAlive())
minion->Respawn();
else if(!minion->getVictim())
else if (!minion->getVictim())
minion->AI()->DoZoneInCombat();
break;
}
@@ -101,23 +101,23 @@ void InstanceData::UpdateDoorState(GameObject *door)
{
DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry());
DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry());
if(lower == upper)
if (lower == upper)
return;
bool open = true;
for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr)
{
if(itr->second.type == DOOR_TYPE_ROOM)
if (itr->second.type == DOOR_TYPE_ROOM)
{
if(itr->second.bossInfo->state == IN_PROGRESS)
if (itr->second.bossInfo->state == IN_PROGRESS)
{
open = false;
break;
}
}
else if(itr->second.type == DOOR_TYPE_PASSAGE)
else if (itr->second.type == DOOR_TYPE_PASSAGE)
{
if(itr->second.bossInfo->state != DONE)
if (itr->second.bossInfo->state != DONE)
{
open = false;
break;
@@ -133,15 +133,15 @@ void InstanceData::AddDoor(GameObject *door, bool add)
{
DoorInfoMap::iterator lower = doors.lower_bound(door->GetEntry());
DoorInfoMap::iterator upper = doors.upper_bound(door->GetEntry());
if(lower == upper)
if (lower == upper)
return;
for (DoorInfoMap::iterator itr = lower; itr != upper; ++itr)
{
if(add)
if (add)
{
itr->second.bossInfo->door[itr->second.type].insert(door);
switch(itr->second.boundary)
switch (itr->second.boundary)
{
default:
case BOUNDARY_NONE:
@@ -168,17 +168,17 @@ void InstanceData::AddDoor(GameObject *door, bool add)
itr->second.bossInfo->door[itr->second.type].erase(door);
}
if(add)
if (add)
UpdateDoorState(door);
}
void InstanceData::AddMinion(Creature *minion, bool add)
{
MinionInfoMap::iterator itr = minions.find(minion->GetEntry());
if(itr == minions.end())
if (itr == minions.end())
return;
if(add)
if (add)
itr->second.bossInfo->minion.insert(minion);
else
itr->second.bossInfo->minion.erase(minion);
@@ -186,10 +186,10 @@ void InstanceData::AddMinion(Creature *minion, bool add)
bool InstanceData::SetBossState(uint32 id, EncounterState state)
{
if(id < bosses.size())
if (id < bosses.size())
{
BossInfo *bossInfo = &bosses[id];
if(bossInfo->state == TO_BE_DECIDED) // loading
if (bossInfo->state == TO_BE_DECIDED) // loading
{
bossInfo->state = state;
//sLog.outError("Inialize boss %u state as %u.", id, (uint32)state);
@@ -197,10 +197,10 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state)
}
else
{
if(bossInfo->state == state)
if (bossInfo->state == state)
return false;
if(state == DONE)
if (state == DONE)
for (MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
if((*i)->isWorldBoss() && (*i)->isAlive())
return false;
@@ -223,14 +223,15 @@ bool InstanceData::SetBossState(uint32 id, EncounterState state)
std::string InstanceData::LoadBossState(const char * data)
{
if(!data) return NULL;
if(!data)
return NULL;
std::istringstream loadStream(data);
uint32 buff;
uint32 bossId = 0;
for (std::vector<BossInfo>::iterator i = bosses.begin(); i != bosses.end(); ++i, ++bossId)
{
loadStream >> buff;
if(buff < TO_BE_DECIDED)
if (buff < TO_BE_DECIDED)
SetBossState(bossId, (EncounterState)buff);
}
return loadStream.str();
@@ -270,8 +271,8 @@ void InstanceData::DoRespawnGameObject(uint64 uiGuid, uint32 uiTimeToDespawn)
if (GameObject* pGo = instance->GetGameObject(uiGuid))
{
//not expect any of these should ever be handled
if (pGo->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR ||
pGo->GetGoType()==GAMEOBJECT_TYPE_BUTTON || pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP)
if (pGo->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE || pGo->GetGoType()==GAMEOBJECT_TYPE_DOOR ||
pGo->GetGoType() == GAMEOBJECT_TYPE_BUTTON || pGo->GetGoType()==GAMEOBJECT_TYPE_TRAP)
return;
if (pGo->isSpawned())
@@ -288,16 +289,13 @@ void InstanceData::DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData)
if (!lPlayers.isEmpty())
{
for (Map::PlayerList::const_iterator itr = lPlayers.begin(); itr != lPlayers.end(); ++itr)
{
if (Player* pPlayer = itr->getSource())
if (Player *pPlayer = itr->getSource())
pPlayer->SendUpdateWorldState(uiStateId, uiStateData);
}
}
else
debug_log("TSCR: DoUpdateWorldState attempt send data but no players in map.");
}
/* Not used anywhere yet, not sure if they're needed:
// Send Notify to all players in instance
void InstanceData::DoSendNotifyToInstance(const char *format, ...)
{
@@ -306,10 +304,11 @@ void InstanceData::DoSendNotifyToInstance(const char *format, ...)
if (!PlayerList.isEmpty())
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (i->getSource() && i->getSource()->GetSession())
i->getSource()->GetSession()->SendNotification(format);
if (Player *pPlayer = i->getSource())
if (WorldSession *pSession = pPlayer->GetSession())
pSession->SendNotification(format);
}
*/
// Complete Achievement for all players in instance
void InstanceData::DoCompleteAchievement(uint32 achievement)
{
@@ -318,8 +317,8 @@ void InstanceData::DoCompleteAchievement(uint32 achievement)
if (!PlayerList.isEmpty())
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (i->getSource())
i->getSource()->CompletedAchievement(AE);
if (Player *pPlayer = i->getSource())
pPlayer->CompletedAchievement(AE);
}
// Remove Auras due to Spell on all players in instance
@@ -329,6 +328,6 @@ void InstanceData::DoRemoveAurasDueToSpellOnPlayers(uint32 spell)
if (!PlayerList.isEmpty())
for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
if (i->getSource())
i->getSource()->RemoveAurasDueToSpell(spell);
if (Player* pPlayer = i->getSource())
pPlayer->RemoveAurasDueToSpell(spell);
}
-2
View File
@@ -152,10 +152,8 @@ class TRINITY_DLL_SPEC InstanceData : public ZoneScript
//sends world state update to all players in instance
void DoUpdateWorldState(uint32 uiStateId, uint32 uiStateData);
/* Not used anywhere yet, not sure if they're needed:
// Send Notify to all players in instance
void DoSendNotifyToInstance(const char *format,...);
*/
// Complete Achievement for all players in instance
void DoCompleteAchievement(uint32 achievement);
+1 -1
View File
@@ -522,7 +522,7 @@ struct ItemPrototype
uint32 AllowableClass;
uint32 AllowableRace;
uint32 ItemLevel;
uint32 RequiredLevel;
uint8 RequiredLevel;
uint32 RequiredSkill; // id from SkillLine.dbc
uint32 RequiredSkillRank;
uint32 RequiredSpell; // id from Spell.dbc
+2 -2
View File
@@ -1743,7 +1743,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* /*args*/)
pet->SetReactState(REACT_DEFENSIVE);
// calculate proper level
uint32 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();
uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();
// prepare visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
@@ -2139,7 +2139,7 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
uint32 accId = 0;
uint32 money = 0;
uint32 total_player_time = 0;
uint32 level = 0;
uint8 level = 0;
uint32 latency = 0;
uint8 race;
uint8 Class;
+8 -7
View File
@@ -152,7 +152,8 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
uint32 clientcount = 0;
uint32 level_min, level_max, racemask, classmask, zones_count, str_count;
uint8 level_min, level_max;
uint32 racemask, classmask, zones_count, str_count;
uint32 zoneids[10]; // 10 is client limit
std::string player_name, guild_name;
@@ -166,7 +167,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
recv_data >> classmask; // class mask
recv_data >> zones_count; // zones count, client limit=10 (2.0.10)
if(zones_count > 10)
if (zones_count > 10)
return; // can't be received from real client or broken packet
for (uint32 i = 0; i < zones_count; ++i)
@@ -179,7 +180,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
recv_data >> str_count; // user entered strings count, client limit=4 (checked on 2.0.10)
if(str_count > 4)
if (str_count > 4)
return; // can't be received from real client or broken packet
sLog.outDebug("Minlvl %u, maxlvl %u, name %s, guild %s, racemask %u, classmask %u, zones %u, strings %u", level_min, level_max, player_name.c_str(), guild_name.c_str(), racemask, classmask, zones_count, str_count);
@@ -190,7 +191,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
std::string temp;
recv_data >> temp; // user entered string, it used as universal search pattern(guild+player name)?
if(!Utf8toWStr(temp,str[i]))
if (!Utf8toWStr(temp,str[i]))
continue;
wstrToLower(str[i]);
@@ -200,14 +201,14 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
std::wstring wplayer_name;
std::wstring wguild_name;
if(!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name)))
if (!(Utf8toWStr(player_name, wplayer_name) && Utf8toWStr(guild_name, wguild_name)))
return;
wstrToLower(wplayer_name);
wstrToLower(wguild_name);
// client send in case not set max level value 100 but mangos support 255 max level,
// update it to show GMs with characters after 100 level
if(level_max >= MAX_LEVEL)
if (level_max >= MAX_LEVEL)
level_max = STRONG_MAX_LEVEL;
uint32 team = _player->GetTeam();
@@ -243,7 +244,7 @@ void WorldSession::HandleWhoOpcode( WorldPacket & recv_data )
continue;
// check if target's level is in level range
uint32 lvl = itr->second->getLevel();
uint8 lvl = itr->second->getLevel();
if (lvl < level_min || lvl > level_max)
continue;
+118 -122
View File
@@ -1914,7 +1914,7 @@ void ObjectMgr::LoadItemPrototypes()
{
ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype >(i);
ItemEntry const *dbcitem = sItemStore.LookupEntry(i);
if(!proto)
if (!proto)
{
/* to many errors, and possible not all items really used in game
if (dbcitem)
@@ -1923,9 +1923,9 @@ void ObjectMgr::LoadItemPrototypes()
continue;
}
if(dbcitem)
if (dbcitem)
{
if(proto->Class != dbcitem->Class)
if (proto->Class != dbcitem->Class)
{
sLog.outErrorDb("Item (Entry: %u) not correct class %u, must be %u (still using DB value).",i,proto->Class,dbcitem->Class);
// It safe let use Class from DB
@@ -1939,71 +1939,69 @@ void ObjectMgr::LoadItemPrototypes()
}
*/
if(proto->Unk0 != dbcitem->Unk0)
if (proto->Unk0 != dbcitem->Unk0)
{
sLog.outErrorDb("Item (Entry: %u) not correct %i Unk0, must be %i (still using DB value).",i,proto->Unk0,dbcitem->Unk0);
// It safe let use Unk0 from DB
}
if(proto->Material != dbcitem->Material)
if (proto->Material != dbcitem->Material)
{
sLog.outErrorDb("Item (Entry: %u) not correct %i material, must be %i (still using DB value).",i,proto->Material,dbcitem->Material);
// It safe let use Material from DB
}
if(proto->InventoryType != dbcitem->InventoryType)
if (proto->InventoryType != dbcitem->InventoryType)
{
sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType);
// It safe let use InventoryType from DB
}
if(proto->DisplayInfoID != dbcitem->DisplayId)
if (proto->DisplayInfoID != dbcitem->DisplayId)
{
sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId);
const_cast<ItemPrototype*>(proto)->DisplayInfoID = dbcitem->DisplayId;
}
if(proto->Sheath != dbcitem->Sheath)
if (proto->Sheath != dbcitem->Sheath)
{
sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).",i,proto->Sheath,dbcitem->Sheath);
const_cast<ItemPrototype*>(proto)->Sheath = dbcitem->Sheath;
}
}
else
{
sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existed items).",i);
}
if(proto->Class >= MAX_ITEM_CLASS)
if (proto->Class >= MAX_ITEM_CLASS)
{
sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class);
const_cast<ItemPrototype*>(proto)->Class = ITEM_CLASS_MISC;
}
if(proto->SubClass >= MaxItemSubclassValues[proto->Class])
if (proto->SubClass >= MaxItemSubclassValues[proto->Class])
{
sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class);
const_cast<ItemPrototype*>(proto)->SubClass = 0;// exist for all item classes
}
if(proto->Quality >= MAX_ITEM_QUALITY)
if (proto->Quality >= MAX_ITEM_QUALITY)
{
sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality);
const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL;
}
if(proto->BuyCount <= 0)
if (proto->BuyCount <= 0)
{
sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount);
const_cast<ItemPrototype*>(proto)->BuyCount = 1;
}
if(proto->InventoryType >= MAX_INVTYPE)
if (proto->InventoryType >= MAX_INVTYPE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType);
const_cast<ItemPrototype*>(proto)->InventoryType = INVTYPE_NON_EQUIP;
}
if(proto->RequiredSkill >= MAX_SKILL_TYPE)
if (proto->RequiredSkill >= MAX_SKILL_TYPE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill);
const_cast<ItemPrototype*>(proto)->RequiredSkill = 0;
@@ -2011,20 +2009,18 @@ void ObjectMgr::LoadItemPrototypes()
{
// can be used in equip slot, as page read use in inventory, or spell casting at use
bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText;
if(!req)
{
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
bool req = proto->InventoryType != INVTYPE_NON_EQUIP || proto->PageText;
if (!req)
for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
{
if(proto->Spells[j].SpellId)
if (proto->Spells[j].SpellId)
{
req = true;
break;
}
}
}
if(req)
if (req)
{
if(!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE))
sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped or use.",i,proto->AllowableClass);
@@ -2034,71 +2030,71 @@ void ObjectMgr::LoadItemPrototypes()
}
}
if(proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell))
if (proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell))
{
sLog.outErrorDb("Item (Entry: %u) have wrong (non-existed) spell in RequiredSpell (%u)",i,proto->RequiredSpell);
const_cast<ItemPrototype*>(proto)->RequiredSpell = 0;
}
if(proto->RequiredReputationRank >= MAX_REPUTATION_RANK)
if (proto->RequiredReputationRank >= MAX_REPUTATION_RANK)
sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank);
if(proto->RequiredReputationFaction)
if (proto->RequiredReputationFaction)
{
if(!sFactionStore.LookupEntry(proto->RequiredReputationFaction))
if (!sFactionStore.LookupEntry(proto->RequiredReputationFaction))
{
sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction);
const_cast<ItemPrototype*>(proto)->RequiredReputationFaction = 0;
}
if(proto->RequiredReputationRank == MIN_REPUTATION_RANK)
if (proto->RequiredReputationRank == MIN_REPUTATION_RANK)
sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i);
}
if(proto->MaxCount < -1)
if (proto->MaxCount < -1)
{
sLog.outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",i,proto->MaxCount);
const_cast<ItemPrototype*>(proto)->MaxCount = -1;
}
if(proto->Stackable == 0)
if (proto->Stackable == 0)
{
sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",i,proto->Stackable);
const_cast<ItemPrototype*>(proto)->Stackable = 1;
}
else if(proto->Stackable < -1)
else if (proto->Stackable < -1)
{
sLog.outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.",i,proto->Stackable);
const_cast<ItemPrototype*>(proto)->Stackable = -1;
}
else if(proto->Stackable > 1000)
else if (proto->Stackable > 1000)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (1000).",i,proto->Stackable);
const_cast<ItemPrototype*>(proto)->Stackable = 1000;
}
if(proto->ContainerSlots > MAX_BAG_SIZE)
if (proto->ContainerSlots > MAX_BAG_SIZE)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",i,proto->ContainerSlots,MAX_BAG_SIZE);
const_cast<ItemPrototype*>(proto)->ContainerSlots = MAX_BAG_SIZE;
}
if(proto->StatsCount > MAX_ITEM_PROTO_STATS)
if (proto->StatsCount > MAX_ITEM_PROTO_STATS)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS);
const_cast<ItemPrototype*>(proto)->StatsCount = MAX_ITEM_PROTO_STATS;
}
for (int j = 0; j < MAX_ITEM_PROTO_STATS; ++j)
for (uint8 j = 0; j < MAX_ITEM_PROTO_STATS; ++j)
{
// for ItemStatValue != 0
if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
if (proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD)
{
sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType);
const_cast<ItemPrototype*>(proto)->ItemStat[j].ItemStatType = 0;
}
switch(proto->ItemStat[j].ItemStatType)
switch (proto->ItemStat[j].ItemStatType)
{
case ITEM_MOD_SPELL_HEALING_DONE:
case ITEM_MOD_SPELL_DAMAGE_DONE:
@@ -2109,7 +2105,7 @@ void ObjectMgr::LoadItemPrototypes()
}
}
for (int j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
for (uint8 j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
{
if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL)
{
@@ -2119,10 +2115,10 @@ void ObjectMgr::LoadItemPrototypes()
}
// special format
if((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET))
if ((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET))
{
// spell_1
if(proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
if (proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger);
const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0;
@@ -2132,14 +2128,14 @@ void ObjectMgr::LoadItemPrototypes()
}
// spell_2 have learning spell
if(proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
if (proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
{
sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger);
const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0;
const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0;
const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
}
else if(!proto->Spells[1].SpellId)
else if (!proto->Spells[1].SpellId)
{
sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.",i,1+1);
const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0;
@@ -2148,7 +2144,7 @@ void ObjectMgr::LoadItemPrototypes()
else
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId);
if(!spellInfo)
if (!spellInfo)
{
sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId);
const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0;
@@ -2156,7 +2152,7 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
}
// allowed only in special format
else if((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN_PET))
else if ((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId == SPELL_ID_GENERIC_LEARN_PET))
{
sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId);
const_cast<ItemPrototype*>(proto)->Spells[0].SpellId = 0;
@@ -2166,15 +2162,15 @@ void ObjectMgr::LoadItemPrototypes()
}
// spell_3*,spell_4*,spell_5* is empty
for (int j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
for (uint8 j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
{
if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
if (proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger);
const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0;
const_cast<ItemPrototype*>(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
}
else if(proto->Spells[j].SpellId != 0)
else if (proto->Spells[j].SpellId != 0)
{
sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format",i,j+1,proto->Spells[j].SpellId);
const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0;
@@ -2184,9 +2180,9 @@ void ObjectMgr::LoadItemPrototypes()
// normal spell list
else
{
for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
for (uint8 j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j)
{
if(proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
if (proto->Spells[j].SpellTrigger >= MAX_ITEM_SPELLTRIGGER || proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
{
sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger);
const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0;
@@ -2196,13 +2192,13 @@ void ObjectMgr::LoadItemPrototypes()
if(proto->Spells[j].SpellId)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId);
if(!spellInfo)
if (!spellInfo)
{
sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId);
const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0;
}
// allowed only in special format
else if((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET))
else if ((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET))
{
sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId);
const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0;
@@ -2211,66 +2207,66 @@ void ObjectMgr::LoadItemPrototypes()
}
}
if(proto->Bonding >= MAX_BIND_TYPE)
if (proto->Bonding >= MAX_BIND_TYPE)
sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",i,proto->Bonding);
if(proto->PageText && !sPageTextStore.LookupEntry<PageText>(proto->PageText))
if (proto->PageText && !sPageTextStore.LookupEntry<PageText>(proto->PageText))
sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i,proto->PageText);
if(proto->LockID && !sLockStore.LookupEntry(proto->LockID))
if (proto->LockID && !sLockStore.LookupEntry(proto->LockID))
sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)",i,proto->LockID);
if(proto->Sheath >= MAX_SHEATHETYPE)
if (proto->Sheath >= MAX_SHEATHETYPE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath);
const_cast<ItemPrototype*>(proto)->Sheath = SHEATHETYPE_NONE;
}
if(proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty)))
if (proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty)))
{
sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty);
const_cast<ItemPrototype*>(proto)->RandomProperty = 0;
}
if(proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix)))
if (proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix)))
{
sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix);
const_cast<ItemPrototype*>(proto)->RandomSuffix = 0;
}
if(proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet))
if (proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet))
{
sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",i,proto->ItemSet);
const_cast<ItemPrototype*>(proto)->ItemSet = 0;
}
if(proto->Area && !GetAreaEntryByAreaID(proto->Area))
if (proto->Area && !GetAreaEntryByAreaID(proto->Area))
sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)",i,proto->Area);
if(proto->Map && !sMapStore.LookupEntry(proto->Map))
if (proto->Map && !sMapStore.LookupEntry(proto->Map))
sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map);
if(proto->BagFamily)
if (proto->BagFamily)
{
// check bits
for (uint32 j = 0; j < sizeof(proto->BagFamily)*8; ++j)
{
uint32 mask = 1 << j;
if((proto->BagFamily & mask)==0)
if ((proto->BagFamily & mask)==0)
continue;
ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1);
if(!bf)
if (!bf)
{
sLog.outErrorDb("Item (Entry: %u) has bag family bit set not listed in ItemBagFamily.dbc, remove bit",i);
const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask;
continue;
}
if(BAG_FAMILY_MASK_CURRENCY_TOKENS & mask)
if (BAG_FAMILY_MASK_CURRENCY_TOKENS & mask)
{
CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(proto->ItemId);
if(!ctEntry)
if (!ctEntry)
{
sLog.outErrorDb("Item (Entry: %u) has currency bag family bit set in BagFamily but not listed in CurrencyTypes.dbc, remove bit",i);
const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask;
@@ -2279,34 +2275,34 @@ void ObjectMgr::LoadItemPrototypes()
}
}
if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory))
if (proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory))
sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory);
for (int j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
for (uint8 j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
{
if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color)
if (proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color)
{
sLog.outErrorDb("Item (Entry: %u) has wrong socketColor_%d (%u)",i,j+1,proto->Socket[j].Color);
const_cast<ItemPrototype*>(proto)->Socket[j].Color = 0;
}
}
if(proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties))
if (proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties))
sLog.outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties);
if(proto->FoodType >= MAX_PET_DIET)
if (proto->FoodType >= MAX_PET_DIET)
{
sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType);
const_cast<ItemPrototype*>(proto)->FoodType = 0;
}
if(proto->ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(proto->ItemLimitCategory))
if (proto->ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(proto->ItemLimitCategory))
{
sLog.outErrorDb("Item (Entry: %u) has wrong LimitCategory value (%u)",i,proto->ItemLimitCategory);
const_cast<ItemPrototype*>(proto)->ItemLimitCategory = 0;
}
if(proto->HolidayId && !sHolidaysStore.LookupEntry(proto->HolidayId))
if (proto->HolidayId && !sHolidaysStore.LookupEntry(proto->HolidayId))
{
sLog.outErrorDb("Item (Entry: %u) has wrong HolidayId value (%u)", i, proto->HolidayId);
const_cast<ItemPrototype*>(proto)->HolidayId = 0;
@@ -2508,7 +2504,7 @@ void ObjectMgr::LoadPetLevelInfo()
}
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
if(pInfo[level].health == 0)
{
@@ -2519,7 +2515,7 @@ void ObjectMgr::LoadPetLevelInfo()
}
}
PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const
PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint8 level) const
{
if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL);
@@ -2842,7 +2838,7 @@ void ObjectMgr::LoadPlayerInfo()
continue;
}
uint32 current_level = fields[1].GetUInt32();
uint8 current_level = fields[1].GetUInt8();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
@@ -2893,7 +2889,7 @@ void ObjectMgr::LoadPlayerInfo()
}
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
if(pClassInfo->levelInfo[level].basehealth == 0)
{
@@ -3011,7 +3007,7 @@ void ObjectMgr::LoadPlayerInfo()
}
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
if(pInfo->levelInfo[level].stats[0] == 0)
{
@@ -3025,7 +3021,7 @@ void ObjectMgr::LoadPlayerInfo()
// Loading xp per level data
{
mPlayerXPperLevel.resize(sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
for (uint32 level = 0; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
for (uint8 level = 0; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
mPlayerXPperLevel[level] = 0;
// 0 1
@@ -3077,9 +3073,9 @@ void ObjectMgr::LoadPlayerInfo()
}
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
for (uint8 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
if( mPlayerXPperLevel[level] == 0)
if (mPlayerXPperLevel[level] == 0)
{
sLog.outErrorDb("Level %i does not have XP for level data. Using data of level [%i] + 100.",level+1, level);
mPlayerXPperLevel[level] = mPlayerXPperLevel[level-1]+100;
@@ -3087,29 +3083,29 @@ void ObjectMgr::LoadPlayerInfo()
}
}
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint8 level, PlayerClassLevelInfo* info) const
{
if(level < 1 || class_ >= MAX_CLASSES)
if (level < 1 || class_ >= MAX_CLASSES)
return;
PlayerClassInfo const* pInfo = &playerClassInfo[class_];
if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
if (level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL);
*info = pInfo->levelInfo[level-1];
}
void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const
void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const
{
if(level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
return;
PlayerInfo const* pInfo = &playerInfo[race][class_];
if(pInfo->displayId_m==0 || pInfo->displayId_f==0)
if (pInfo->displayId_m==0 || pInfo->displayId_f==0)
return;
if(level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
if (level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
*info = pInfo->levelInfo[level-1];
else
BuildPlayerLevelInfo(race,class_,level,info);
@@ -3198,10 +3194,10 @@ void ObjectMgr::LoadGuilds()
QueryResult *result = CharacterDatabase.Query( "SELECT guildid FROM guild" );
if( !result )
if (!result)
{
barGoLink bar( 1 );
barGoLink bar(1);
bar.step();
@@ -3210,7 +3206,7 @@ void ObjectMgr::LoadGuilds()
return;
}
barGoLink bar( result->GetRowCount() );
barGoLink bar(result->GetRowCount());
do
{
@@ -3220,7 +3216,7 @@ void ObjectMgr::LoadGuilds()
++count;
newguild = new Guild;
if(!newguild->LoadGuildFromDB(fields[0].GetUInt32()))
if (!newguild->LoadGuildFromDB(fields[0].GetUInt32()))
{
newguild->Disband();
delete newguild;
@@ -3228,7 +3224,7 @@ void ObjectMgr::LoadGuilds()
}
AddGuild(newguild);
}while( result->NextRow() );
}while (result->NextRow());
delete result;
@@ -6380,25 +6376,25 @@ void ObjectMgr::LoadExplorationBaseXP()
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp");
if( !result )
if (!result)
{
barGoLink bar( 1 );
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString( ">> Loaded %u BaseXP definitions", count );
sLog.outString(">> Loaded %u BaseXP definitions", count);
return;
}
barGoLink bar( result->GetRowCount() );
barGoLink bar(result->GetRowCount());
do
{
bar.step();
Field *fields = result->Fetch();
uint32 level = fields[0].GetUInt32();
uint8 level = fields[0].GetUInt8();
uint32 basexp = fields[1].GetUInt32();
mBaseXPTable[level] = basexp;
++count;
@@ -6411,12 +6407,12 @@ void ObjectMgr::LoadExplorationBaseXP()
sLog.outString( ">> Loaded %u BaseXP definitions", count );
}
uint32 ObjectMgr::GetBaseXP(uint32 level)
uint32 ObjectMgr::GetBaseXP(uint8 level)
{
return mBaseXPTable[level] ? mBaseXPTable[level] : 0;
}
uint32 ObjectMgr::GetXPForLevel(uint32 level)
uint32 ObjectMgr::GetXPForLevel(uint8 level)
{
if (level < mPlayerXPperLevel.size())
return mPlayerXPperLevel[level];
@@ -6428,9 +6424,9 @@ void ObjectMgr::LoadPetNames()
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation");
if( !result )
if (!result)
{
barGoLink bar( 1 );
barGoLink bar(1);
bar.step();
@@ -6439,7 +6435,7 @@ void ObjectMgr::LoadPetNames()
return;
}
barGoLink bar( result->GetRowCount() );
barGoLink bar(result->GetRowCount());
do
{
@@ -6449,7 +6445,7 @@ void ObjectMgr::LoadPetNames()
std::string word = fields[0].GetString();
uint32 entry = fields[1].GetUInt32();
bool half = fields[2].GetBool();
if(half)
if (half)
PetHalfName1[entry].push_back(word);
else
PetHalfName0[entry].push_back(word);
@@ -6465,14 +6461,14 @@ void ObjectMgr::LoadPetNames()
void ObjectMgr::LoadPetNumber()
{
QueryResult* result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
if(result)
if (result)
{
Field *fields = result->Fetch();
m_hiPetNumber = fields[0].GetUInt32()+1;
delete result;
}
barGoLink bar( 1 );
barGoLink bar(1);
bar.step();
sLog.outString();
@@ -6484,11 +6480,11 @@ std::string ObjectMgr::GeneratePetName(uint32 entry)
std::vector<std::string> & list0 = PetHalfName0[entry];
std::vector<std::string> & list1 = PetHalfName1[entry];
if(list0.empty() || list1.empty())
if (list0.empty() || list1.empty())
{
CreatureInfo const *cinfo = GetCreatureTemplate(entry);
char* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale());
if(!petname)
if (!petname)
petname = cinfo->Name;
return std::string(petname);
}
@@ -6504,21 +6500,21 @@ uint32 ObjectMgr::GeneratePetNumber()
void ObjectMgr::LoadCorpses()
{
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 10
// 0 1 2 3 4 5 6 7 8 10
QueryResult *result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0");
if( !result )
if(!result)
{
barGoLink bar( 1 );
barGoLink bar(1);
bar.step();
sLog.outString();
sLog.outString( ">> Loaded %u corpses", count );
sLog.outString(">> Loaded %u corpses", count);
return;
}
barGoLink bar( result->GetRowCount() );
barGoLink bar(result->GetRowCount());
do
{
@@ -6529,7 +6525,7 @@ void ObjectMgr::LoadCorpses()
uint32 guid = fields[result->GetFieldCount()-1].GetUInt32();
Corpse *corpse = new Corpse;
if(!corpse->LoadFromDB(guid,fields))
if (!corpse->LoadFromDB(guid,fields))
{
delete corpse;
continue;
@@ -6543,7 +6539,7 @@ void ObjectMgr::LoadCorpses()
delete result;
sLog.outString();
sLog.outString( ">> Loaded %u corpses", count );
sLog.outString(">> Loaded %u corpses", count);
}
void ObjectMgr::LoadReputationOnKill()
@@ -6587,26 +6583,26 @@ void ObjectMgr::LoadReputationOnKill()
repOnKill.repvalue2 = fields[8].GetInt32();
repOnKill.team_dependent = fields[9].GetUInt8();
if(!GetCreatureTemplate(creature_id))
if (!GetCreatureTemplate(creature_id))
{
sLog.outErrorDb("Table `creature_onkill_reputation` have data for not existed creature entry (%u), skipped",creature_id);
continue;
}
if(repOnKill.repfaction1)
if (repOnKill.repfaction1)
{
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1);
if(!factionEntry1)
if (!factionEntry1)
{
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction1);
continue;
}
}
if(repOnKill.repfaction2)
if (repOnKill.repfaction2)
{
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2);
if(!factionEntry2)
if (!factionEntry2)
{
sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction2);
continue;
@@ -6628,7 +6624,7 @@ void ObjectMgr::LoadPointsOfInterest()
{
uint32 count = 0;
// 0 1 2 3 4 5
// 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.Query("SELECT entry, x, y, icon, flags, data, icon_name FROM points_of_interest");
if(!result)
@@ -6659,7 +6655,7 @@ void ObjectMgr::LoadPointsOfInterest()
POI.data = fields[5].GetUInt32();
POI.icon_name = fields[6].GetCppString();
if(!MaNGOS::IsValidMapCoord(POI.x,POI.y))
if (!MaNGOS::IsValidMapCoord(POI.x,POI.y))
{
sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.",point_id,POI.x,POI.y);
continue;
+5 -5
View File
@@ -415,14 +415,14 @@ class ObjectMgr
return sInstanceTemplate.LookupEntry<InstanceTemplate>(map);
}
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const;
PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint8 level) const;
PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
{
if(class_ >= MAX_CLASSES) return NULL;
return &playerClassInfo[class_];
}
void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const;
void GetPlayerClassLevelInfo(uint32 class_,uint8 level, PlayerClassLevelInfo* info) const;
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
{
@@ -432,7 +432,7 @@ class ObjectMgr
if(info->displayId_m==0 || info->displayId_f==0) return NULL;
return info;
}
void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const;
void GetPlayerLevelInfo(uint32 race, uint32 class_, uint8 level, PlayerLevelInfo* info) const;
uint64 GetPlayerGUIDByName(std::string name) const;
bool GetPlayerNameByGUID(const uint64 &guid, std::string &name) const;
@@ -606,8 +606,8 @@ class ObjectMgr
void LoadGMTickets();
std::string GeneratePetName(uint32 entry);
uint32 GetBaseXP(uint32 level);
uint32 GetXPForLevel(uint32 level);
uint32 GetBaseXP(uint8 level);
uint32 GetXPForLevel(uint8 level);
int32 GetFishingBaseSkillLevel(uint32 entry) const
{
+125 -128
View File
@@ -702,7 +702,7 @@ void Pet::GivePetXP(uint32 xp)
if(!isAlive())
return;
uint32 level = getLevel();
uint8 level = getLevel();
// XP to money conversion processed in Player::RewardQuest
if(level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
@@ -732,9 +732,9 @@ void Pet::GivePetXP(uint32 xp)
SetUInt32Value(UNIT_FIELD_PETEXPERIENCE, newXP);
}
void Pet::GivePetLevel(uint32 level)
void Pet::GivePetLevel(uint8 level)
{
if(!level)
if (!level)
return;
InitStatsForLevel(level);
@@ -798,7 +798,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
}
// TODO: Move stat mods code to pet passive auras
bool Guardian::InitStatsForLevel(uint32 petlevel)
bool Guardian::InitStatsForLevel(uint8 petlevel)
{
CreatureInfo const *cinfo = GetCreatureInfo();
assert(cinfo);
@@ -849,7 +849,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
//resistance
int32 createResistance[MAX_SPELL_SCHOOL] = {0,0,0,0,0,0,0};
if(cinfo && petType != HUNTER_PET)
if (cinfo && petType != HUNTER_PET)
{
createResistance[SPELL_SCHOOL_HOLY] = cinfo->resistance1;
createResistance[SPELL_SCHOOL_FIRE] = cinfo->resistance2;
@@ -863,13 +863,13 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
//health, mana, armor and resistance
PetLevelInfo const* pInfo = objmgr.GetPetLevelInfo(creature_ID, petlevel);
if(pInfo) // exist in DB
if (pInfo) // exist in DB
{
SetCreateHealth(pInfo->health);
if(petType != HUNTER_PET) //hunter pet use focus
if (petType != HUNTER_PET) //hunter pet use focus
SetCreateMana(pInfo->mana);
if(pInfo->armor > 0)
if (pInfo->armor > 0)
SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
for (uint8 stat = 0; stat < MAX_STATS; ++stat)
@@ -889,7 +889,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
m_bonusdamage = 0;
switch(petType)
switch (petType)
{
case SUMMON_PET:
{
@@ -919,7 +919,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
default:
{
switch(GetEntry())
switch (GetEntry())
{
case 510: // mage Water Elemental
{
@@ -932,7 +932,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
case 1964: //force of nature
{
if(!pInfo)
if (!pInfo)
SetCreateHealth(30 + 30*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2)));
@@ -940,7 +940,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
case 15352: //earth elemental 36213
{
if(!pInfo)
if (!pInfo)
SetCreateHealth(100 + 120*petlevel);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
@@ -948,7 +948,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
case 15438: //fire elemental
{
if(!pInfo)
if (!pInfo)
{
SetCreateHealth(40*petlevel);
SetCreateMana(28 + 10*petlevel);
@@ -959,8 +959,8 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
case 31216: // Mirror Image
{
SetBonusDamage( int32(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FROST) * 0.33f));
if(!pInfo)
SetBonusDamage(int32(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FROST) * 0.33f));
if (!pInfo)
{
SetCreateMana(28 + 30*petlevel);
SetCreateHealth(28 + 10*petlevel);
@@ -970,7 +970,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
case 27829: // Ebon Gargoyle
{
SetBonusDamage( int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.4f));
if(!pInfo)
if (!pInfo)
{
SetCreateMana(28 + 10*petlevel);
SetCreateHealth(28 + 30*petlevel);
@@ -979,7 +979,7 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
}
default:
{
if(!pInfo)
if (!pInfo)
{
SetCreateMana(28 + 10*petlevel);
SetCreateHealth(28 + 30*petlevel);
@@ -1010,11 +1010,11 @@ bool Pet::HaveInDiet(ItemPrototype const* item) const
return false;
CreatureInfo const* cInfo = GetCreatureInfo();
if(!cInfo)
if (!cInfo)
return false;
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
if(!cFamily)
if (!cFamily)
return false;
uint32 diet = cFamily->petFoodMask;
@@ -1077,14 +1077,12 @@ void Pet::_LoadSpellCooldowns()
sLog.outDebug("Pet (Number: %u) spell %u cooldown loaded (%u secs).", m_charmInfo->GetPetNumber(), spell_id, uint32(db_time-curTime));
}
while( result->NextRow() );
while (result->NextRow());
delete result;
if(!m_CreatureSpellCooldowns.empty() && GetOwner())
{
((Player*)GetOwner())->GetSession()->SendPacket(&data);
}
}
}
@@ -1097,7 +1095,7 @@ void Pet::_SaveSpellCooldowns()
// remove oudated and save active
for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end(); )
{
if(itr->second <= curTime)
if (itr->second <= curTime)
m_CreatureSpellCooldowns.erase(itr++);
else
{
@@ -1111,7 +1109,7 @@ void Pet::_LoadSpells()
{
QueryResult *result = CharacterDatabase.PQuery("SELECT spell,active FROM pet_spell WHERE guid = '%u'",m_charmInfo->GetPetNumber());
if(result)
if (result)
{
do
{
@@ -1119,7 +1117,7 @@ void Pet::_LoadSpells()
addSpell(fields[0].GetUInt32(), ActiveStates(fields[1].GetUInt8()), PETSPELL_UNCHANGED);
}
while( result->NextRow() );
while (result->NextRow());
delete result;
}
@@ -1135,7 +1133,7 @@ void Pet::_SaveSpells()
if (itr->second.type == PETSPELL_FAMILY)
continue;
switch(itr->second.state)
switch (itr->second.state)
{
case PETSPELL_REMOVED:
CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u' and spell = '%u'", m_charmInfo->GetPetNumber(), itr->first);
@@ -1160,9 +1158,9 @@ void Pet::_LoadAuras(uint32 timediff)
{
sLog.outDebug("Loading auras for pet %u",GetGUIDLow());
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2 ,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_mask,stackcount,amount0,amount1,amount2,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());
if(result)
if (result)
{
do
{
@@ -1170,14 +1168,14 @@ void Pet::_LoadAuras(uint32 timediff)
Field *fields = result->Fetch();
uint64 caster_guid = fields[0].GetUInt64();
uint32 spellid = fields[1].GetUInt32();
uint32 effmask = fields[2].GetUInt32();
uint32 stackcount = fields[3].GetUInt32();
damage[0] = int32(fields[4].GetUInt32());
damage[1] = int32(fields[5].GetUInt32());
damage[2] = int32(fields[6].GetUInt32());
int32 maxduration = (int32)fields[7].GetUInt32();
int32 remaintime = (int32)fields[8].GetUInt32();
int32 remaincharges = (int32)fields[9].GetUInt32();
uint8 effmask = fields[2].GetUInt8();
uint8 stackcount = fields[3].GetUInt8();
damage[0] = fields[4].GetInt32();
damage[1] = fields[5].GetInt32();
damage[2] = fields[6].GetInt32();
int32 maxduration = fields[7].GetInt32();
int32 remaintime = fields[8].GetInt32();
uint8 remaincharges = fields[9].GetUInt8();
SpellEntry const* spellproto = sSpellStore.LookupEntry(spellid);
if(!spellproto)
@@ -1214,7 +1212,7 @@ void Pet::_LoadAuras(uint32 timediff)
AddAura(aura);
sLog.outDetail("Added aura spellid %u, effectmask %u", spellproto->Id, effmask);
}
while( result->NextRow() );
while (result->NextRow());
delete result;
}
@@ -1227,7 +1225,7 @@ void Pet::_SaveAuras()
AuraMap const& auras = GetAuras();
for (AuraMap::const_iterator itr = auras.begin(); itr !=auras.end() ; ++itr)
{
if(!itr->second->CanBeSaved())
if (!itr->second->CanBeSaved())
continue;
int32 amounts[MAX_SPELL_EFFECTS];
@@ -1239,11 +1237,11 @@ void Pet::_SaveAuras()
amounts[i] = 0;
}
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0, amount1, amount2,maxduration,remaintime,remaincharges) "
"VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%d', '%u')",
m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(), itr->second->GetId(), (uint32)itr->second->GetEffectMask(),
(int32)itr->second->GetStackAmount(), amounts[0], amounts[1], amounts[2]
,itr->second->GetAuraMaxDuration(), itr->second->GetAuraDuration(), (uint32)itr->second->GetAuraCharges());
CharacterDatabase.PExecute("INSERT INTO pet_aura (guid,caster_guid,spell,effect_mask,stackcount,amount0,amount1,amount2,maxduration,remaintime,remaincharges) "
"VALUES ('%u', '" UI64FMTD "', '%u', '%u', '%u', '%d', '%d', '%d', '%d', '%d', '%u')",
m_charmInfo->GetPetNumber(), itr->second->GetCasterGUID(), itr->second->GetId(), itr->second->GetEffectMask(),
itr->second->GetStackAmount(), amounts[0], amounts[1], amounts[2],
itr->second->GetAuraMaxDuration(), itr->second->GetAuraDuration(),itr->second->GetAuraCharges());
}
}
@@ -1253,7 +1251,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
if (!spellInfo)
{
// do pet spell book cleanup
if(state == PETSPELL_UNCHANGED) // spell load case
if (state == PETSPELL_UNCHANGED) // spell load case
{
sLog.outError("Pet::addSpell: Non-existed in SpellStore spell #%u request, deleting for all pets in `pet_spell`.",spell_id);
CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'",spell_id);
@@ -1277,9 +1275,9 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
// can be in case spell loading but learned at some previous spell loading
itr->second.state = PETSPELL_UNCHANGED;
if(active == ACT_ENABLED)
if (active == ACT_ENABLED)
ToggleAutocast(spell_id, true);
else if(active == ACT_DISABLED)
else if (active == ACT_DISABLED)
ToggleAutocast(spell_id, false);
return false;
@@ -1294,9 +1292,9 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
newspell.state = state;
newspell.type = type;
if(active == ACT_DECIDE) //active was not used before, so we save it's autocast/passive state here
if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here
{
if(IsAutocastableSpell(spell_id))
if (IsAutocastableSpell(spell_id))
newspell.active = ACT_DISABLED;
else
newspell.active = ACT_PASSIVE;
@@ -1305,19 +1303,19 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
newspell.active = active;
// talent: unlearn all other talent ranks (high and low)
if(TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id))
if (TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id))
{
if(TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id ))
if (TalentEntry const *talentInfo = sTalentStore.LookupEntry( talentPos->talent_id ))
{
for (uint8 i=0; i < MAX_TALENT_RANK; ++i)
for (uint8 i = 0; i < MAX_TALENT_RANK; ++i)
{
// skip learning spell and no rank spell case
uint32 rankSpellId = talentInfo->RankID[i];
if(!rankSpellId || rankSpellId==spell_id)
if (!rankSpellId || rankSpellId==spell_id)
continue;
// skip unknown ranks
if(!HasSpell(rankSpellId))
if (!HasSpell(rankSpellId))
continue;
removeSpell(rankSpellId,false,false);
}
@@ -1327,16 +1325,16 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
{
for (PetSpellMap::const_iterator itr2 = m_spells.begin(); itr2 != m_spells.end(); ++itr2)
{
if(itr2->second.state == PETSPELL_REMOVED) continue;
if (itr2->second.state == PETSPELL_REMOVED) continue;
if( spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) )
if (spellmgr.IsRankSpellDueToSpell(spellInfo,itr2->first) )
{
// replace by new high rank
if(spellmgr.IsHighRankOfSpell(spell_id,itr2->first))
if (spellmgr.IsHighRankOfSpell(spell_id,itr2->first))
{
newspell.active = itr2->second.active;
if(newspell.active == ACT_ENABLED)
if (newspell.active == ACT_ENABLED)
ToggleAutocast(itr2->first, false);
oldspell_id = itr2->first;
@@ -1344,7 +1342,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
break;
}
// ignore new lesser rank
else if(spellmgr.IsHighRankOfSpell(itr2->first,spell_id))
else if (spellmgr.IsHighRankOfSpell(itr2->first,spell_id))
return false;
}
}
@@ -1364,7 +1362,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
if (talentCost)
{
int32 free_points = GetMaxTalentPointsForLevel(getLevel());
m_usedTalentCount+=talentCost;
m_usedTalentCount += talentCost;
// update free talent points
free_points-=m_usedTalentCount;
SetFreeTalentPoints(free_points > 0 ? free_points : 0);
@@ -1378,7 +1376,7 @@ bool Pet::learnSpell(uint32 spell_id)
if (!addSpell(spell_id))
return false;
if(!m_loading)
if (!m_loading)
{
WorldPacket data(SMSG_PET_LEARNED_SPELL, 4);
data << uint32(spell_id);
@@ -1390,15 +1388,15 @@ bool Pet::learnSpell(uint32 spell_id)
void Pet::InitLevelupSpellsForLevel()
{
uint32 level = getLevel();
uint8 level = getLevel();
if(PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL)
if (PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL)
{
// PetLevelupSpellSet ordered by levels, process in reversed order
for (PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
{
// will called first if level down
if(itr->first > level)
if (itr->first > level)
unlearnSpell(itr->second,true); // will learn prev rank if any
// will called if level up
else
@@ -1414,11 +1412,11 @@ void Pet::InitLevelupSpellsForLevel()
for (uint8 i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i)
{
SpellEntry const* spellEntry = sSpellStore.LookupEntry(defSpells->spellid[i]);
if(!spellEntry)
if (!spellEntry)
continue;
// will called first if level down
if(spellEntry->spellLevel > level)
if (spellEntry->spellLevel > level)
unlearnSpell(spellEntry->Id,true);
// will called if level up
else
@@ -1429,9 +1427,9 @@ void Pet::InitLevelupSpellsForLevel()
bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
{
if(removeSpell(spell_id,learn_prev,clear_ab))
if (removeSpell(spell_id,learn_prev,clear_ab))
{
if(!m_loading)
if (!m_loading)
{
WorldPacket data(SMSG_PET_REMOVED_SPELL, 4);
data << uint32(spell_id);
@@ -1448,10 +1446,10 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
if (itr == m_spells.end())
return false;
if(itr->second.state == PETSPELL_REMOVED)
if (itr->second.state == PETSPELL_REMOVED)
return false;
if(itr->second.state == PETSPELL_NEW)
if (itr->second.state == PETSPELL_NEW)
m_spells.erase(itr);
else
itr->second.state = PETSPELL_REMOVED;
@@ -1462,7 +1460,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
if (talentCost > 0)
{
if (m_usedTalentCount > talentCost)
m_usedTalentCount-=talentCost;
m_usedTalentCount -= talentCost;
else
m_usedTalentCount = 0;
// update free talent points
@@ -1481,7 +1479,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
// if remove last rank or non-ranked then update action bar at server and client if need
if (clear_ab && !learn_prev && m_charmInfo->RemoveSpellFromActionBar(spell_id))
{
if(!m_loading)
if (!m_loading)
{
// need update action bar for last removed rank
if (Unit* owner = GetOwner())
@@ -1496,12 +1494,12 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
void Pet::CleanupActionBar()
{
for (uint8 i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)
if(UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i))
if(ab->GetAction() && ab->IsActionBarForSpell())
if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i))
if (ab->GetAction() && ab->IsActionBarForSpell())
{
if(!HasSpell(ab->GetAction()))
if (!HasSpell(ab->GetAction()))
m_charmInfo->SetActionBar(i, 0, ACT_PASSIVE);
else if(ab->GetType() == ACT_ENABLED)
else if (ab->GetType() == ACT_ENABLED)
ToggleAutocast(ab->GetAction(), true);
}
}
@@ -1524,20 +1522,20 @@ bool Pet::resetTalents(bool no_cost)
return false;
// not need after this call
if(((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true);
CreatureInfo const * ci = GetCreatureInfo();
if(!ci)
if (!ci)
return false;
// Check pet talent type
CreatureFamilyEntry const *pet_family = sCreatureFamilyStore.LookupEntry(ci->family);
if(!pet_family || pet_family->petTalentType < 0)
if (!pet_family || pet_family->petTalentType < 0)
return false;
Player *player = (Player *)owner;
uint32 level = getLevel();
uint8 level = getLevel();
uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
if (m_usedTalentCount == 0)
@@ -1548,13 +1546,13 @@ bool Pet::resetTalents(bool no_cost)
uint32 cost = 0;
if(!no_cost)
if (!no_cost)
{
cost = resetTalentsCost();
if (player->GetMoney() < cost)
{
player->SendBuyError( BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, 0, 0, 0);
return false;
}
}
@@ -1563,22 +1561,23 @@ bool Pet::resetTalents(bool no_cost)
{
TalentEntry const *talentInfo = sTalentStore.LookupEntry(i);
if (!talentInfo) continue;
if (!talentInfo)
continue;
TalentTabEntry const *talentTabInfo = sTalentTabStore.LookupEntry( talentInfo->TalentTab );
if(!talentTabInfo)
if (!talentTabInfo)
continue;
// unlearn only talents for pets family talent type
if(!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
if (!((1 << pet_family->petTalentType) & talentTabInfo->petTalentMask))
continue;
for (int j = 0; j < MAX_TALENT_RANK; j++)
for (uint8 j = 0; j < MAX_TALENT_RANK; ++j)
{
for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); )
{
if(itr->second.state == PETSPELL_REMOVED)
if (itr->second.state == PETSPELL_REMOVED)
{
++itr;
continue;
@@ -1601,14 +1600,14 @@ bool Pet::resetTalents(bool no_cost)
SetFreeTalentPoints(talentPointsForLevel);
if(!no_cost)
if (!no_cost)
{
player->ModifyMoney(-(int32)cost);
m_resetTalentsCost = cost;
m_resetTalentsTime = time(NULL);
}
if(!m_loading)
if (!m_loading)
player->PetSpellInitialize();
return true;
}
@@ -1616,11 +1615,11 @@ bool Pet::resetTalents(bool no_cost)
void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
{
// not need after this call
if(((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
if (((Player*)owner)->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
((Player*)owner)->RemoveAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS,true);
// reset for online
if(online_pet)
if (online_pet)
online_pet->resetTalents(true);
// now need only reset for offline pets (all pets except online case)
@@ -1631,7 +1630,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
owner->GetGUIDLow(),except_petnumber);
// no offline pets
if(!resultPets)
if (!resultPets)
return;
QueryResult *result = CharacterDatabase.PQuery(
@@ -1639,7 +1638,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
"WHERE character_pet.owner = '%u' AND character_pet.id = pet_spell.guid AND character_pet.id <> %u",
owner->GetGUIDLow(),except_petnumber);
if(!result)
if (!result)
{
delete resultPets;
return;
@@ -1662,7 +1661,7 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
need_comma = true;
}
while( resultPets->NextRow() );
while (resultPets->NextRow());
delete resultPets;
@@ -1675,21 +1674,21 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
uint32 spell = fields[0].GetUInt32();
if(!GetTalentSpellCost(spell))
if (!GetTalentSpellCost(spell))
continue;
if(need_execute)
if (need_execute)
ss << ",";
ss << spell;
need_execute = true;
}
while( result->NextRow() );
while (result->NextRow());
delete result;
if(!need_execute)
if (!need_execute)
return;
ss << ")";
@@ -1699,21 +1698,19 @@ void Pet::resetTalentsForAllPetsOf(Player* owner, Pet* online_pet /*= NULL*/)
void Pet::InitTalentForLevel()
{
uint32 level = getLevel();
uint8 level = getLevel();
uint32 talentPointsForLevel = GetMaxTalentPointsForLevel(level);
// Reset talents in case low level (on level down) or wrong points for level (hunter can unlearn TP increase talent)
if(talentPointsForLevel == 0 || m_usedTalentCount > talentPointsForLevel)
{
// Remove all talent points
resetTalents(true);
}
resetTalents(true); // Remove all talent points
SetFreeTalentPoints(talentPointsForLevel - m_usedTalentCount);
Unit *owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
if(!m_loading)
if (!m_loading)
((Player*)owner)->SendTalentsInfoData(true);
}
@@ -1722,20 +1719,20 @@ uint32 Pet::resetTalentsCost() const
uint32 days = (sWorld.GetGameTime() - m_resetTalentsTime)/DAY;
// The first time reset costs 10 silver; after 1 day cost is reset to 10 silver
if(m_resetTalentsCost < 10*SILVER || days > 0)
if (m_resetTalentsCost < 10*SILVER || days > 0)
return 10*SILVER;
// then 50 silver
else if(m_resetTalentsCost < 50*SILVER)
else if (m_resetTalentsCost < 50*SILVER)
return 50*SILVER;
// then 1 gold
else if(m_resetTalentsCost < 1*GOLD)
else if (m_resetTalentsCost < 1*GOLD)
return 1*GOLD;
// then increasing at a rate of 1 gold; cap 10 gold
else
return (m_resetTalentsCost + 1*GOLD > 10*GOLD ? 10*GOLD : m_resetTalentsCost + 1*GOLD);
}
uint8 Pet::GetMaxTalentPointsForLevel(uint32 level)
uint8 Pet::GetMaxTalentPointsForLevel(uint8 level)
{
uint8 points = (level >= 20) ? ((level - 16) / 4) : 0;
// Mod points from owner SPELL_AURA_MOD_PET_TALENT_POINTS
@@ -1746,16 +1743,16 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level)
void Pet::ToggleAutocast(uint32 spellid, bool apply)
{
if(!IsAutocastableSpell(spellid))
if (!IsAutocastableSpell(spellid))
return;
PetSpellMap::iterator itr = m_spells.find(spellid);
if(itr == m_spells.end())
if (itr == m_spells.end())
return;
uint32 i;
if(apply)
if (apply)
{
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i)
; // just search
@@ -1764,10 +1761,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{
m_autospells.push_back(spellid);
if(itr->second.active != ACT_ENABLED)
if (itr->second.active != ACT_ENABLED)
{
itr->second.active = ACT_ENABLED;
if(itr->second.state != PETSPELL_NEW)
if (itr->second.state != PETSPELL_NEW)
itr->second.state = PETSPELL_CHANGED;
}
}
@@ -1775,7 +1772,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
else
{
AutoSpellList::iterator itr2 = m_autospells.begin();
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, itr2++)
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, ++itr2)
; // just search
if (i < m_autospells.size())
@@ -1793,10 +1790,10 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
bool Pet::IsPermanentPetFor(Player* owner)
{
switch(getPetType())
switch (getPetType())
{
case SUMMON_PET:
switch(owner->getClass())
switch (owner->getClass())
{
case CLASS_WARLOCK:
return GetCreatureInfo()->type == CREATURE_TYPE_DEMON;
@@ -1823,7 +1820,7 @@ bool Pet::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint3
m_DBTableGuid = guidlow;
m_originalEntry = Entry;
if(!InitEntry(Entry))
if (!InitEntry(Entry))
return false;
SetSheath(SHEATH_STATE_MELEE);
@@ -1834,22 +1831,22 @@ bool Pet::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint3
bool Pet::HasSpell(uint32 spell) const
{
PetSpellMap::const_iterator itr = m_spells.find(spell);
return (itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED );
return itr != m_spells.end() && itr->second.state != PETSPELL_REMOVED;
}
// Get all passive spells in our skill line
void Pet::LearnPetPassives()
{
CreatureInfo const* cInfo = GetCreatureInfo();
if(!cInfo)
if (!cInfo)
return;
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->family);
if(!cFamily)
if (!cFamily)
return;
PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID);
if(petStore != sPetFamilySpellsStore.end())
if (petStore != sPetFamilySpellsStore.end())
{
// For general hunter pets skill 270
// Passive 01~10, Passive 00 (20782, not used), Ferocious Inspiration (34457)
@@ -1862,10 +1859,10 @@ void Pet::LearnPetPassives()
void Pet::CastPetAuras(bool current)
{
Unit* owner = GetOwner();
if(!owner || owner->GetTypeId() != TYPEID_PLAYER)
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
if(!IsPermanentPetFor((Player*)owner))
if (!IsPermanentPetFor((Player*)owner))
return;
for (PetAuraSet::const_iterator itr = owner->m_petAuras.begin(); itr != owner->m_petAuras.end(); )
@@ -1873,7 +1870,7 @@ void Pet::CastPetAuras(bool current)
PetAura const* pa = *itr;
++itr;
if(!current && pa->IsRemovedOnChangePet())
if (!current && pa->IsRemovedOnChangePet())
owner->RemovePetAura(pa);
else
CastPetAura(pa);
@@ -1883,10 +1880,10 @@ void Pet::CastPetAuras(bool current)
void Pet::CastPetAura(PetAura const* aura)
{
uint32 auraId = aura->GetAura(GetEntry());
if(!auraId)
if (!auraId)
return;
if(auraId == 35696) // Demonic Knowledge
if (auraId == 35696) // Demonic Knowledge
{
int32 basePoints = int32(aura->GetDamage() * (GetStat(STAT_STAMINA) + GetStat(STAT_INTELLECT)) / 100);
CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true);
@@ -1899,7 +1896,7 @@ void Pet::learnSpellHighRank(uint32 spellid)
{
learnSpell(spellid);
if(uint32 next = spellmgr.GetNextSpellInChain(spellid))
if (uint32 next = spellmgr.GetNextSpellInChain(spellid))
learnSpellHighRank(next);
}
@@ -1909,7 +1906,7 @@ void Pet::SynchronizeLevelWithOwner()
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return;
switch(getPetType())
switch (getPetType())
{
// always same level
case SUMMON_PET:
@@ -1917,7 +1914,7 @@ void Pet::SynchronizeLevelWithOwner()
break;
// can't be greater owner level
case HUNTER_PET:
if(getLevel() > owner->getLevel())
if (getLevel() > owner->getLevel())
{
GivePetLevel(owner->getLevel());
SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, objmgr.GetXPForLevel(owner->getLevel())/4);
+2 -2
View File
@@ -162,7 +162,7 @@ class Pet : public Guardian
void LooseHappiness();
HappinessState GetHappinessState();
void GivePetXP(uint32 xp);
void GivePetLevel(uint32 level);
void GivePetLevel(uint8 level);
void SynchronizeLevelWithOwner();
bool HaveInDiet(ItemPrototype const* item) const;
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel);
@@ -213,7 +213,7 @@ class Pet : public Guardian
uint32 resetTalentsCost() const;
void InitTalentForLevel();
uint8 GetMaxTalentPointsForLevel(uint32 level);
uint8 GetMaxTalentPointsForLevel(uint8 level);
uint8 GetFreeTalentPoints() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); }
void SetFreeTalentPoints(uint8 points) { SetByteValue(UNIT_FIELD_BYTES_1, 1, points); }
+433 -441
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -847,7 +847,7 @@ class TRINITY_DLL_SPEC PlayerTaxi
PlayerTaxi();
~PlayerTaxi() {}
// Nodes
void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint32 level);
void InitTaxiNodesForLevel(uint32 race, uint32 chrClass, uint8 level);
void LoadTaxiMask(const char* data);
bool IsTaximaskNodeKnown(uint32 nodeidx) const
@@ -1010,7 +1010,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SetPvPDeath(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
void GiveXP(uint32 xp, Unit* victim);
void GiveLevel(uint32 level);
void GiveLevel(uint8 level);
void InitStatsForLevel(bool reapplyMods = false);
@@ -2347,8 +2347,8 @@ Spell * m_spellModTakingSpell;
PlayerTalentMap *m_talents[MAX_TALENT_SPECS];
uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use
uint32 m_activeSpec;
uint32 m_specsCount;
uint8 m_activeSpec;
uint8 m_specsCount;
uint32 m_Glyphs[MAX_TALENT_SPECS][MAX_GLYPH_SLOT_INDEX];
+130 -142
View File
@@ -3533,49 +3533,47 @@ void Spell::EffectProficiency(uint32 /*i*/)
void Spell::EffectSummonType(uint32 i)
{
uint32 entry = m_spellInfo->EffectMiscValue[i];
if(!entry)
if (!entry)
return;
SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(m_spellInfo->EffectMiscValueB[i]);
if(!properties)
if (!properties)
{
sLog.outError("EffectSummonType: Unhandled summon type %u", m_spellInfo->EffectMiscValueB[i]);
return;
}
if(!m_originalCaster)
if (!m_originalCaster)
return;
int32 duration = GetSpellDuration(m_spellInfo);
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
Position pos;
GetSummonPosition(i, pos);
/*//totem must be at same Z in case swimming caster and etc.
if( fabs( z - m_caster->GetPositionZ() ) > 5 )
if (fabs(z - m_caster->GetPositionZ()) > 5)
z = m_caster->GetPositionZ();
uint32 level = m_caster->getLevel();
uint8 level = m_caster->getLevel();
// level of creature summoned using engineering item based at engineering skill level
if(m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem)
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem)
{
ItemPrototype const *proto = m_CastItem->GetProto();
if(proto && proto->RequiredSkill == SKILL_ENGINERING)
if (proto && proto->RequiredSkill == SKILL_ENGINERING)
{
uint16 skill202 = ((Player*)m_caster)->GetSkillValue(SKILL_ENGINERING);
if(skill202)
{
if (skill202)
level = skill202/5;
}
}
}*/
TempSummon *summon = NULL;
switch(properties->Category)
switch (properties->Category)
{
default:
if (properties->Flags & 512)
@@ -3583,7 +3581,7 @@ void Spell::EffectSummonType(uint32 i)
SummonGuardian(i, entry, properties);
break;
}
switch(properties->Type)
switch (properties->Type)
{
case SUMMON_TYPE_PET:
case SUMMON_TYPE_GUARDIAN:
@@ -3598,10 +3596,10 @@ void Spell::EffectSummonType(uint32 i)
case SUMMON_TYPE_TOTEM:
{
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
if(!summon || !summon->isTotem())
if (!summon || !summon->isTotem())
return;
if(damage) // if not spell info, DB values used
if (damage) // if not spell info, DB values used
{
summon->SetMaxHealth(damage);
summon->SetHealth(damage);
@@ -3609,7 +3607,7 @@ void Spell::EffectSummonType(uint32 i)
//summon->SetUInt32Value(UNIT_CREATED_BY_SPELL,m_spellInfo->Id);
if(m_originalCaster->GetTypeId() == TYPEID_PLAYER
if (m_originalCaster->GetTypeId() == TYPEID_PLAYER
&& properties->Slot >= SUMMON_SLOT_TOTEM
&& properties->Slot < MAX_TOTEM_SLOT)
{
@@ -3626,7 +3624,7 @@ void Spell::EffectSummonType(uint32 i)
case SUMMON_TYPE_MINIPET:
{
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
if(!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
return;
//summon->InitPetCreateSpells(); // e.g. disgusting oozeling has a create spell as summon...
@@ -3639,7 +3637,7 @@ void Spell::EffectSummonType(uint32 i)
std::string name = m_originalCaster->GetName();
name.append(petTypeSuffix[3]);
summon->SetName( name );
summon->SetName(name);
break;
}
default:
@@ -3681,30 +3679,28 @@ void Spell::EffectSummonType(uint32 i)
float x, y, z;
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_caster);
if(!summon || !summon->IsVehicle())
if (!summon || !summon->IsVehicle())
return;
if(damage)
if (damage)
m_caster->CastSpell(summon, damage, true);
m_caster->EnterVehicle(summon->GetVehicleKit());
break;
}
}
if(summon)
{
if (summon)
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
}
}
void Spell::EffectLearnSpell(uint32 i)
{
if(!unitTarget)
if (!unitTarget)
return;
if(unitTarget->GetTypeId() != TYPEID_PLAYER)
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
{
if(m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
EffectLearnPetSpell(i);
return;
@@ -3712,10 +3708,10 @@ void Spell::EffectLearnSpell(uint32 i)
Player *player = (Player*)unitTarget;
uint32 spellToLearn = ((m_spellInfo->Id==SPELL_ID_GENERIC_LEARN) || (m_spellInfo->Id==SPELL_ID_GENERIC_LEARN_PET)) ? damage : m_spellInfo->EffectTriggerSpell[i];
uint32 spellToLearn = (m_spellInfo->Id == SPELL_ID_GENERIC_LEARN || m_spellInfo->Id == SPELL_ID_GENERIC_LEARN_PET) ? damage : m_spellInfo->EffectTriggerSpell[i];
player->learnSpell(spellToLearn,false);
sLog.outDebug( "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow() );
sLog.outDebug("Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow());
}
typedef std::list< std::pair<uint32, uint64> > DispelList;
@@ -3728,7 +3724,7 @@ void Spell::EffectDispel(uint32 i)
// Create dispel mask by dispel type
uint32 dispel_type = m_spellInfo->EffectMiscValue[i];
uint32 dispelMask = GetDispellMask( DispelType(dispel_type) );
uint32 dispelMask = GetDispellMask( DispelType(dispel_type));
Unit::AuraMap const& auras = unitTarget->GetAuras();
for (Unit::AuraMap::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
@@ -3817,7 +3813,7 @@ void Spell::EffectDispel(uint32 i)
void Spell::EffectDualWield(uint32 /*i*/)
{
unitTarget->SetCanDualWield(true);
if(unitTarget->GetTypeId() == TYPEID_UNIT)
if (unitTarget->GetTypeId() == TYPEID_UNIT)
((Creature*)unitTarget)->UpdateDamagePhysical(OFF_ATTACK);
}
@@ -3834,12 +3830,12 @@ void Spell::EffectDistract(uint32 /*i*/)
return;
// target must be OK to do this
if( unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING ) )
if (unitTarget->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_STUNNED | UNIT_STAT_FLEEING))
return;
float angle = unitTarget->GetAngle(&m_targets.m_dstPos);
if ( unitTarget->GetTypeId() == TYPEID_PLAYER )
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
{
// For players just turn them
((Player*)unitTarget)->SetPosition(unitTarget->GetPositionX(), unitTarget->GetPositionY(), unitTarget->GetPositionZ(), angle, false);
@@ -3856,15 +3852,15 @@ void Spell::EffectDistract(uint32 /*i*/)
void Spell::EffectPickPocket(uint32 /*i*/)
{
if( m_caster->GetTypeId() != TYPEID_PLAYER )
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
// victim must be creature and attackable
if( !unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget) )
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget))
return;
// victim have to be alive and humanoid or undead
if( unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0)
if (unitTarget->isAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0)
{
int32 chance = 10 + int32(m_caster->getLevel()) - int32(unitTarget->getLevel());
@@ -3909,10 +3905,10 @@ void Spell::EffectAddFarsight(uint32 i)
void Spell::EffectTeleUnitsFaceCaster(uint32 i)
{
if(!unitTarget)
if (!unitTarget)
return;
if(unitTarget->isInFlight())
if (unitTarget->isInFlight())
return;
float dis = m_caster->GetSpellRadiusForTarget(unitTarget, sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
@@ -3925,10 +3921,10 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i)
void Spell::EffectLearnSkill(uint32 i)
{
if(unitTarget->GetTypeId() != TYPEID_PLAYER)
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
if(damage < 0)
if (damage < 0)
return;
uint32 skillid = m_spellInfo->EffectMiscValue[i];
@@ -3938,11 +3934,11 @@ void Spell::EffectLearnSkill(uint32 i)
void Spell::EffectAddHonor(uint32 /*i*/)
{
if(unitTarget->GetTypeId() != TYPEID_PLAYER)
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
// not scale value for item based reward (/10 value expected)
if(m_CastItem)
if (m_CastItem)
{
((Player*)unitTarget)->RewardHonor(NULL, 1, damage/10);
sLog.outError("SpellEffect::AddHonor (spell_id %u) rewards %d honor points (item %u) for player: %u", m_spellInfo->Id, damage/10, m_CastItem->GetEntry(),((Player*)unitTarget)->GetGUIDLow());
@@ -3950,7 +3946,7 @@ void Spell::EffectAddHonor(uint32 /*i*/)
}
// do not allow to add too many honor for player (50 * 21) = 1040 at level 70, or (50 * 31) = 1550 at level 80
if( damage <= 50)
if (damage <= 50)
{
uint32 honor_reward = MaNGOS::Honor::hk_honor_at_level(unitTarget->getLevel(), damage);
((Player*)unitTarget)->RewardHonor(NULL, 1, honor_reward);
@@ -3966,7 +3962,7 @@ void Spell::EffectAddHonor(uint32 /*i*/)
void Spell::EffectTradeSkill(uint32 /*i*/)
{
if(unitTarget->GetTypeId() != TYPEID_PLAYER)
if (unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
// uint32 skillid = m_spellInfo->EffectMiscValue[i];
// uint16 skillmax = ((Player*)unitTarget)->(skillid);
@@ -3975,7 +3971,7 @@ void Spell::EffectTradeSkill(uint32 /*i*/)
void Spell::EffectEnchantItemPerm(uint32 effect_idx)
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
if (!itemTarget)
return;
@@ -3986,7 +3982,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx)
if (itemTarget->IsWeaponVellum() || itemTarget->IsArmorVellum())
{
// destroy one vellum from stack
uint32 count=1;
uint32 count = 1;
p_caster->DestroyItemCount(itemTarget,count,true);
unitTarget=p_caster;
// and add a scroll
@@ -4010,7 +4006,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx)
// item can be in trade slot and have owner diff. from caster
Player* item_owner = itemTarget->GetOwner();
if(!item_owner)
if (!item_owner)
return;
if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
@@ -4033,7 +4029,7 @@ void Spell::EffectEnchantItemPerm(uint32 effect_idx)
void Spell::EffectEnchantItemPrismatic(uint32 effect_idx)
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
if (!itemTarget)
return;
@@ -4069,10 +4065,10 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx)
// item can be in trade slot and have owner diff. from caster
Player* item_owner = itemTarget->GetOwner();
if(!item_owner)
if (!item_owner)
return;
if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
{
sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(perm): %s (Entry: %d) for player: %s (Account: %u)",
p_caster->GetName(),p_caster->GetSession()->GetAccountId(),
@@ -4091,18 +4087,18 @@ void Spell::EffectEnchantItemPrismatic(uint32 effect_idx)
void Spell::EffectEnchantItemTmp(uint32 i)
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
Player* p_caster = (Player*)m_caster;
if(!itemTarget)
if (!itemTarget)
return;
uint32 enchant_id = m_spellInfo->EffectMiscValue[i];
// Shaman Rockbiter Weapon
if(i==0 && m_spellInfo->Effect[1]==SPELL_EFFECT_DUMMY)
if (i == 0 && m_spellInfo->Effect[1] == SPELL_EFFECT_DUMMY)
{
int32 enchnting_damage = CalculateDamage(1, NULL);//+1;
@@ -4110,7 +4106,7 @@ void Spell::EffectEnchantItemTmp(uint32 i)
// with already applied percent bonus from Elemental Weapons talent
// Note: damage calculated (correctly) with rounding int32(float(v)) but
// RW enchantments applied damage int32(float(v)+0.5), this create 0..1 difference sometime
switch(enchnting_damage)
switch (enchnting_damage)
{
// Rank 1
case 2: enchant_id = 29; break; // 0% [ 7% == 2, 14% == 2, 20% == 2]
@@ -4162,7 +4158,7 @@ void Spell::EffectEnchantItemTmp(uint32 i)
}
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if(!pEnchant)
if (!pEnchant)
{
sLog.outError("Spell %u Effect %u (SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY) have not existed enchanting id %u ",m_spellInfo->Id,i,enchant_id);
return;
@@ -4172,26 +4168,26 @@ void Spell::EffectEnchantItemTmp(uint32 i)
uint32 duration;
// rogue family enchantments exception by duration
if(m_spellInfo->Id == 38615)
if (m_spellInfo->Id == 38615)
duration = 1800; // 30 mins
// other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints)
else if(m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE)
else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE)
duration = 3600; // 1 hour
// shaman family enchantments
else if(m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN)
else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN)
duration = 1800; // 30 mins
// other cases with this SpellVisual already selected
else if(m_spellInfo->SpellVisual[0] == 215)
else if (m_spellInfo->SpellVisual[0] == 215)
duration = 1800; // 30 mins
// some fishing pole bonuses
else if(m_spellInfo->SpellVisual[0] == 563)
else if (m_spellInfo->SpellVisual[0] == 563)
duration = 600; // 10 mins
// shaman rockbiter enchantments
else if(m_spellInfo->SpellVisual[0] == 0)
else if (m_spellInfo->SpellVisual[0] == 0)
duration = 1800; // 30 mins
else if(m_spellInfo->Id == 29702)
else if (m_spellInfo->Id == 29702)
duration = 300; // 5 mins
else if(m_spellInfo->Id == 37360)
else if (m_spellInfo->Id == 37360)
duration = 300; // 5 mins
// default case
else
@@ -4199,10 +4195,10 @@ void Spell::EffectEnchantItemTmp(uint32 i)
// item can be in trade slot and have owner diff. from caster
Player* item_owner = itemTarget->GetOwner();
if(!item_owner)
if (!item_owner)
return;
if(item_owner!=p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
if (item_owner != p_caster && p_caster->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE) )
{
sLog.outCommand(p_caster->GetSession()->GetAccountId(),"GM %s (Account: %u) enchanting(temp): %s (Entry: %d) for player: %s (Account: %u)",
p_caster->GetName(), p_caster->GetSession()->GetAccountId(),
@@ -4221,21 +4217,21 @@ void Spell::EffectEnchantItemTmp(uint32 i)
void Spell::EffectTameCreature(uint32 /*i*/)
{
if(m_caster->GetPetGUID())
if (m_caster->GetPetGUID())
return;
if(!unitTarget)
if (!unitTarget)
return;
if(unitTarget->GetTypeId() != TYPEID_UNIT)
if (unitTarget->GetTypeId() != TYPEID_UNIT)
return;
Creature* creatureTarget = (Creature*)unitTarget;
if(creatureTarget->isPet())
if (creatureTarget->isPet())
return;
if(m_caster->getClass() != CLASS_HUNTER)
if (m_caster->getClass() != CLASS_HUNTER)
return;
// cast finish successfully
@@ -4243,13 +4239,13 @@ void Spell::EffectTameCreature(uint32 /*i*/)
finish();
Pet* pet = m_caster->CreateTamedPetFrom(creatureTarget,m_spellInfo->Id);
if(!pet) // in versy specific state like near world end/etc.
if (!pet) // in very specific state like near world end/etc.
return;
// "kill" original creature
creatureTarget->ForcedDespawn();
uint32 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel();
uint8 level = (creatureTarget->getLevel() < (m_caster->getLevel() - 5)) ? (m_caster->getLevel() - 5) : creatureTarget->getLevel();
// prepare visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);
@@ -4265,7 +4261,7 @@ void Spell::EffectTameCreature(uint32 /*i*/)
pet->InitTalentForLevel();
if(m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
((Player*)m_caster)->PetSpellInitialize();
@@ -4275,7 +4271,7 @@ void Spell::EffectTameCreature(uint32 /*i*/)
void Spell::EffectSummonPet(uint32 i)
{
Player *owner = NULL;
if(m_originalCaster)
if (m_originalCaster)
{
if(m_originalCaster->GetTypeId() == TYPEID_PLAYER)
owner = (Player*)m_originalCaster;
@@ -4285,7 +4281,7 @@ void Spell::EffectSummonPet(uint32 i)
uint32 petentry = m_spellInfo->EffectMiscValue[i];
if(!owner)
if (!owner)
{
SummonPropertiesEntry const *properties = sSummonPropertiesStore.LookupEntry(67);
if(properties)
@@ -4296,12 +4292,12 @@ void Spell::EffectSummonPet(uint32 i)
Pet *OldSummon = owner->GetPet();
// if pet requested type already exist
if( OldSummon )
if (OldSummon)
{
if(petentry == 0 || OldSummon->GetEntry() == petentry)
if (petentry == 0 || OldSummon->GetEntry() == petentry)
{
// pet in corpse state can't be summoned
if( OldSummon->isDead() )
if (OldSummon->isDead())
return;
assert(OldSummon->GetMap() == owner->GetMap());
@@ -4316,14 +4312,13 @@ void Spell::EffectSummonPet(uint32 i)
//OldSummon->SetMap(owner->GetMap());
//owner->GetMap()->Add((Creature*)OldSummon);
if(owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() )
{
if (owner->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() )
((Player*)owner)->PetSpellInitialize();
}
return;
}
if(owner->GetTypeId() == TYPEID_PLAYER)
if (owner->GetTypeId() == TYPEID_PLAYER)
((Player*)owner)->RemovePet(OldSummon,(OldSummon->getPetType()==HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT),false);
else
return;
@@ -4332,12 +4327,12 @@ void Spell::EffectSummonPet(uint32 i)
float x, y, z;
owner->GetClosePoint(x, y, z, owner->GetObjectSize());
Pet* pet = owner->SummonPet(petentry, x, y, z, owner->GetOrientation(), SUMMON_PET, 0);
if(!pet)
if (!pet)
return;
if(m_caster->GetTypeId() == TYPEID_UNIT)
if (m_caster->GetTypeId() == TYPEID_UNIT)
{
if ( ((Creature*)m_caster)->isTotem() )
if (((Creature*)m_caster)->isTotem())
pet->SetReactState(REACT_AGGRESSIVE);
else
pet->SetReactState(REACT_DEFENSIVE);
@@ -4347,25 +4342,25 @@ void Spell::EffectSummonPet(uint32 i)
// generate new name for summon pet
std::string new_name=objmgr.GeneratePetName(petentry);
if(!new_name.empty())
if (!new_name.empty())
pet->SetName(new_name);
}
void Spell::EffectLearnPetSpell(uint32 i)
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
Player *_player = (Player*)m_caster;
Pet *pet = _player->GetPet();
if(!pet)
if (!pet)
return;
if(!pet->isAlive())
if (!pet->isAlive())
return;
SpellEntry const *learn_spellproto = sSpellStore.LookupEntry(m_spellInfo->EffectTriggerSpell[i]);
if(!learn_spellproto)
if (!learn_spellproto)
return;
pet->learnSpell(learn_spellproto->Id);
@@ -4389,20 +4384,20 @@ void Spell::EffectTaunt(uint32 /*i*/)
}
// Also use this effect to set the taunter's threat to the taunted creature's highest value
if(unitTarget->getThreatManager().getCurrentVictim())
if (unitTarget->getThreatManager().getCurrentVictim())
{
float myThreat = unitTarget->getThreatManager().getThreat(m_caster);
float itsThreat = unitTarget->getThreatManager().getCurrentVictim()->getThreat();
if(itsThreat > myThreat)
if (itsThreat > myThreat)
unitTarget->getThreatManager().addThreat(m_caster, itsThreat - myThreat);
}
//Set aggro victim to caster
if( !unitTarget->getThreatManager().getOnlineContainer().empty() )
if(HostilReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster))
if (!unitTarget->getThreatManager().getOnlineContainer().empty())
if (HostilReference* forcedVictim = unitTarget->getThreatManager().getOnlineContainer().getReferenceByTarget(m_caster))
unitTarget->getThreatManager().setCurrentVictim(forcedVictim);
if(((Creature*)unitTarget)->IsAIEnabled && !((Creature*)unitTarget)->HasReactState(REACT_PASSIVE))
if (((Creature*)unitTarget)->IsAIEnabled && !((Creature*)unitTarget)->HasReactState(REACT_PASSIVE))
((Creature*)unitTarget)->AI()->AttackStart(m_caster);
}
@@ -4412,23 +4407,23 @@ void Spell::EffectWeaponDmg(uint32 i)
void Spell::SpellDamageWeaponDmg(uint32 i)
{
if(!unitTarget)
if (!unitTarget)
return;
if(!unitTarget->isAlive())
if (!unitTarget->isAlive())
return;
// multiple weapon dmg effect workaround
// execute only the last weapon damage
// and handle all effects at once
for (int j = i+1; j < 3; ++j)
for (uint32 j = i + 1; j < 3; ++j)
{
switch(m_spellInfo->Effect[j])
switch (m_spellInfo->Effect[j])
{
case SPELL_EFFECT_WEAPON_DAMAGE:
case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL:
case SPELL_EFFECT_NORMALIZED_WEAPON_DMG:
case SPELL_EFFECT_WEAPON_PERCENT_DAMAGE:
return; // we must calculate only at last weapon effect
return; // we must calculate only at last weapon effect
break;
}
}
@@ -4438,12 +4433,12 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
int32 fixed_bonus = 0;
int32 spell_bonus = 0; // bonus specific for spell
switch(m_spellInfo->SpellFamilyName)
switch (m_spellInfo->SpellFamilyName)
{
case SPELLFAMILY_WARRIOR:
{
// Devastate bonus and sunder armor refresh
if(m_spellInfo->SpellFamilyFlags[1] & 0x40)
if (m_spellInfo->SpellFamilyFlags[1] & 0x40)
{
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
@@ -4457,7 +4452,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
stack = aur->GetStackAmount();
}
for (uint8 j = 0; j < 3; j++)
for (uint8 j = 0; j < 3; ++j)
{
if(m_spellInfo->Effect[j] == SPELL_EFFECT_NORMALIZED_WEAPON_DMG)
{
@@ -4473,7 +4468,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
for (PlayerSpellMap::const_iterator itr = sp_list.begin(); itr != sp_list.end(); ++itr)
{
// only highest rank is shown in spell book, so simply check if shown in spell book
if(!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED)
if (!itr->second->active || itr->second->disabled || itr->second->state == PLAYERSPELL_REMOVED)
continue;
SpellEntry const *spellProto = sSpellStore.LookupEntry(itr->first);
@@ -4495,7 +4490,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
// Glyph of Devastate
if (AuraEffect * aurEff = m_caster->GetAuraEffect(58388, 0))
count += aurEff->GetAmount();
for (; count>0; count--)
for (; count > 0; --count)
m_caster->CastSpell(unitTarget, spellInfo, true);
if (stack)
spell_bonus += stack * CalculateDamage(2, unitTarget);
@@ -4505,26 +4500,26 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
case SPELLFAMILY_ROGUE:
{
// Hemorrhage
if(m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
{
if(m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
((Player*)m_caster)->AddComboPoints(unitTarget, 1, this);
}
// Fan of Knives
else if(m_spellInfo->SpellFamilyFlags[1] & 0x40000)
else if (m_spellInfo->SpellFamilyFlags[1] & 0x40000)
{
// 50% more damage with daggers
if(m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (Item* item = ((Player*)m_caster)->GetWeaponForAttack(m_attackType, true))
if (item->GetProto()->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)
totalDamagePercentMod *= 1.5f;
}
// Mutilate (for each hand)
else if(m_spellInfo->SpellFamilyFlags[1] & 0x6)
else if (m_spellInfo->SpellFamilyFlags[1] & 0x6)
{
bool found = false;
// fast check
if(unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON, m_spellInfo, m_caster))
if (unitTarget->HasAuraState(AURA_STATE_DEADLY_POISON, m_spellInfo, m_caster))
found = true;
// full aura scan
else
@@ -4532,7 +4527,7 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
Unit::AuraMap const& auras = unitTarget->GetAuras();
for (Unit::AuraMap::const_iterator itr = auras.begin(); itr!=auras.end(); ++itr)
{
if(itr->second->GetSpellProto()->Dispel == DISPEL_POISON)
if (itr->second->GetSpellProto()->Dispel == DISPEL_POISON)
{
found = true;
break;
@@ -4548,30 +4543,30 @@ void Spell::SpellDamageWeaponDmg(uint32 i)
case SPELLFAMILY_PALADIN:
{
// Seal of Command - receive benefit from Spell Damage and Healing
if(m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
{
spell_bonus += int32(0.23f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo)));
spell_bonus += int32(0.29f*m_caster->SpellBaseDamageBonusForVictim(GetSpellSchoolMask(m_spellInfo), unitTarget));
}
// Seal of Command Unleashed
else if(m_spellInfo->Id==20467)
else if (m_spellInfo->Id==20467)
{
spell_bonus += int32(0.16f*m_caster->GetTotalAttackPowerValue(BASE_ATTACK));
spell_bonus += int32(0.25f*m_caster->SpellBaseDamageBonus(GetSpellSchoolMask(m_spellInfo)));
}
break;
// Judgement of Blood/of the Martyr backlash damage (33%)
if(m_spellInfo->SpellFamilyFlags[0] & 0x0000000800000000LL && m_spellInfo->SpellIconID==153)
if (m_spellInfo->SpellFamilyFlags[0] & 0x0000000800000000LL && m_spellInfo->SpellIconID==153)
{
int32 damagePoint = m_damage * 33 / 100;
if(m_spellInfo->Id == 31898)
if (m_spellInfo->Id == 31898)
m_caster->CastCustomSpell(m_caster, 32220, &damagePoint, NULL, NULL, true);
else
m_caster->CastCustomSpell(m_caster, 53725, &damagePoint, NULL, NULL, true);
}
// Seal of Blood/of the Martyr backlash damage (10%)
else if(m_spellInfo->SpellIconID==2293)
else if (m_spellInfo->SpellIconID==2293)
{
int32 damagePoint = m_damage * 10 / 100;
if(m_spellInfo->Id == 31893)
@@ -7234,10 +7229,10 @@ void Spell::EffectRedirectThreat(uint32 /*i*/)
void Spell::EffectWMODamage(uint32 /*i*/)
{
if(gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
if (gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
{
Unit *caster = m_originalCaster;
if(!caster)
if (!caster)
return;
FactionTemplateEntry const *casterft, *goft;
@@ -7251,40 +7246,33 @@ void Spell::EffectWMODamage(uint32 /*i*/)
void Spell::EffectWMORepair(uint32 /*i*/)
{
if(gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
if (gameObjTarget && gameObjTarget->GetGoType() == GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
gameObjTarget->Rebuild();
}
void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *properties)
{
Unit *caster = m_originalCaster;
if(!caster)
if (!caster)
return;
if(caster->isTotem())
if (caster->isTotem())
caster = ((Totem*)caster)->GetOwner();
// in another case summon new
uint32 level = caster->getLevel();
uint8 level = caster->getLevel();
// level of pet summoned using engineering item based at engineering skill level
if(m_CastItem && caster->GetTypeId() == TYPEID_PLAYER)
{
ItemPrototype const *proto = m_CastItem->GetProto();
if(proto && proto->RequiredSkill == SKILL_ENGINERING)
{
uint16 skill202 = ((Player*)caster)->GetSkillValue(SKILL_ENGINERING);
if(skill202)
{
level = skill202/5;
}
}
}
if (m_CastItem && caster->GetTypeId() == TYPEID_PLAYER)
if (ItemPrototype const *proto = m_CastItem->GetProto())
if (proto->RequiredSkill == SKILL_ENGINERING)
if (uint16 skill202 = ((Player*)caster)->GetSkillValue(SKILL_ENGINERING))
level = skill202/5;
//float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
float radius = 5.0f;
int32 amount = damage > 0 ? damage : 1;
switch(m_spellInfo->Id)
switch (m_spellInfo->Id)
{
case 1122: // Inferno
amount = 1;
@@ -7303,13 +7291,13 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *
GetSummonPosition(i, pos, radius, count);
TempSummon *summon = map->SummonCreature(entry, pos, properties, duration, caster);
if(!summon)
if (!summon)
return;
if(summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
((Guardian*)summon)->InitStatsForLevel(level);
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
if(summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
if (summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)
((Minion*)summon)->SetFollowAngle(m_caster->GetAngle(summon));
summon->AI()->EnterEvadeMode();
@@ -7329,7 +7317,7 @@ void Spell::GetSummonPosition(uint32 i, Position &pos, float radius, uint32 coun
else
{
//This is a workaround. Do not have time to write much about it
switch(m_spellInfo->EffectImplicitTargetA[i])
switch (m_spellInfo->EffectImplicitTargetA[i])
{
case TARGET_MINION:
case TARGET_DEST_CASTER_RANDOM:
@@ -7365,7 +7353,7 @@ void Spell::EffectRenamePet(uint32 /*eff_idx*/)
void Spell::EffectPlayMusic(uint32 i)
{
if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
uint32 soundid = m_spellInfo->EffectMiscValue[i];
@@ -7383,7 +7371,7 @@ void Spell::EffectPlayMusic(uint32 i)
void Spell::EffectSpecCount(uint32 /*eff_idx*/)
{
if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
((Player*)unitTarget)->UpdateSpecCount(damage);
@@ -7391,7 +7379,7 @@ void Spell::EffectSpecCount(uint32 /*eff_idx*/)
void Spell::EffectActivateSpec(uint32 /*eff_idx*/)
{
if(!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
return;
((Player*)unitTarget)->ActivateSpec(damage-1); // damage is 1 or 2, spec is 0 or 1
+8 -7
View File
@@ -443,19 +443,20 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
if (IsInFeralForm()) //check if player is druid and in cat or bear forms
{
uint32 lvl = getLevel();
if ( lvl > 60 ) lvl = 60;
uint8 lvl = getLevel();
if (lvl > 60)
lvl = 60;
weapon_mindamage = lvl*0.85*att_speed;
weapon_maxdamage = lvl*1.25*att_speed;
weapon_mindamage = lvl*0.85f*att_speed;
weapon_maxdamage = lvl*1.25f*att_speed;
}
else if(!CanUseAttackType(attType)) //check if player not in form but still can't use (disarm case)
{
//cannot use ranged/off attack, set values to 0
if (attType != BASE_ATTACK)
{
min_damage=0;
max_damage=0;
min_damage = 0;
max_damage = 0;
return;
}
weapon_mindamage = BASE_MINDAMAGE;
@@ -478,7 +479,7 @@ void Player::UpdateDamagePhysical(WeaponAttackType attType)
CalculateMinMaxDamage(attType, false, true, mindamage, maxdamage);
switch(attType)
switch (attType)
{
case BASE_ATTACK:
default:
+1 -1
View File
@@ -67,7 +67,7 @@ class Guardian : public Minion
public:
Guardian(SummonPropertiesEntry const *properties, Unit *owner);
void InitStats(uint32 duration);
bool InitStatsForLevel(uint32 level);
bool InitStatsForLevel(uint8 level);
void InitSummon();
bool UpdateStats(Stats stat);
+3 -3
View File
@@ -12026,12 +12026,12 @@ float Unit::GetWeaponDamageRange(WeaponAttackType attType ,WeaponDamageRange typ
return m_weaponDamage[attType][type];
}
void Unit::SetLevel(uint32 lvl)
void Unit::SetLevel(uint8 lvl)
{
SetUInt32Value(UNIT_FIELD_LEVEL, lvl);
// group update
if ((GetTypeId() == TYPEID_PLAYER) && ((Player*)this)->GetGroup())
if (GetTypeId() == TYPEID_PLAYER && ((Player*)this)->GetGroup())
((Player*)this)->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_LEVEL);
}
@@ -13513,7 +13513,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
if(GetTypeId() == TYPEID_PLAYER)
pet->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
uint32 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel();
uint8 level = (creatureTarget->getLevel() < (getLevel() - 5)) ? (getLevel() - 5) : creatureTarget->getLevel();
if(!pet->InitStatsForLevel(level))
{
+3 -3
View File
@@ -1167,9 +1167,9 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
bool isTotem() const { return m_unitTypeMask & UNIT_MASK_TOTEM; }
bool IsVehicle() const { return m_unitTypeMask & UNIT_MASK_VEHICLE; }
uint32 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
virtual uint32 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); }
void SetLevel(uint32 lvl);
uint8 getLevel() const { return GetUInt32Value(UNIT_FIELD_LEVEL); }
virtual uint8 getLevelForTarget(Unit const* /*target*/) const { return getLevel(); }
void SetLevel(uint8 lvl);
uint8 getRace() const { return GetByteValue(UNIT_FIELD_BYTES_0, 0); }
uint32 getRaceMask() const { return 1 << (getRace()-1); }
uint8 getClass() const { return GetByteValue(UNIT_FIELD_BYTES_0, 1); }
+1 -1
View File
@@ -518,7 +518,7 @@ class World
/// Get the maximum skill level a player can reach
uint16 GetConfigMaxSkillValue() const
{
uint32 lvl = getConfig(CONFIG_MAX_PLAYER_LEVEL);
uint8 lvl = getConfig(CONFIG_MAX_PLAYER_LEVEL);
return lvl > 60 ? 300 + ((lvl - 60) * 75) / 10 : lvl*5;
}