Skip to content

Commit a232991

Browse files
committed
fix codestyle and add enabled hook list for performance improvement
1 parent 166e2eb commit a232991

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/LS_loader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
void AddSC_LearnAllSpells();
77

8-
void Addmod_learn_spellsScripts() {
8+
void Addmod_learn_spellsScripts()
9+
{
910
AddSC_LearnAllSpells();
1011
}

src/mod_learnspells.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@
99
class LearnSpellsOnLevelUp : public PlayerScript
1010
{
1111
public:
12-
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp") { }
12+
LearnSpellsOnLevelUp() : PlayerScript("LearnSpellsOnLevelUp", {
13+
PLAYERHOOK_ON_FIRST_LOGIN,
14+
PLAYERHOOK_ON_LEVEL_CHANGED
15+
}) { }
1316

1417
void OnPlayerFirstLogin(Player* player) override
1518
{
1619
if (sConfigMgr->GetOption<bool>("LearnSpells.OnFirstLogin", 0))
17-
{
1820
LearnSpellsForNewLevel(player, 1);
21+
22+
if (player->getClass() == CLASS_SHAMAN)
23+
{
24+
player->AddItem(5175, 1); // Earth Totem
25+
player->AddItem(5176, 1); // Fire Totem
26+
player->AddItem(5177, 1); // Water Totem
27+
player->AddItem(5178, 1); // Air Totem
1928
}
20-
if (player->getClass() == CLASS_SHAMAN)
21-
{
22-
player->AddItem(5175, 1); // Earth Totem
23-
player->AddItem(5176, 1); // Fire Totem
24-
player->AddItem(5177, 1); // Water Totem
25-
player->AddItem(5178, 1); // Air Totem
26-
}
2729
}
2830

2931
void OnPlayerLevelChanged(Player* player, uint8 oldLevel) override
@@ -480,9 +482,7 @@ class LearnSpellsOnLevelUp : public PlayerScript
480482
for (auto const& spell : additionalSpellsToTeach)
481483
{
482484
if (!(player->HasSpell(spell.spellId)) && (spell.faction == TeamId::TEAM_NEUTRAL || spell.faction == player->GetTeamId()))
483-
{
484485
player->learnSpell(spell.spellId);
485-
}
486486
}
487487
}
488488
}

0 commit comments

Comments
 (0)