Skip to content

Commit 28e3475

Browse files
authored
Merge pull request #25 from azerothcore/sudlud-pach-42-5
fix codestyle, sql and add enabled hook lists for performance improvement
2 parents 33157b7 + 8c5d41f commit 28e3475

File tree

3 files changed

+15
-60
lines changed

3 files changed

+15
-60
lines changed

data/sql/db-characters/base/morphsummon_ddl.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ CREATE TABLE IF NOT EXISTS `mod_morphsummon_felguard_weapon` (
22
`PlayerGUIDLow` int(10) unsigned NOT NULL,
33
`FelguardItemID` int(10) unsigned NOT NULL COMMENT 'Item ID for Felguard virtual item slot 0',
44
PRIMARY KEY (`PlayerGUIDLow`)
5-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='mod-morphsummon; used for custom Felguard weapons';
5+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='mod-morphsummon; used for custom Felguard weapons';

data/sql/db-world/base/morphsummon.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ INSERT INTO `gossip_menu_option` (`MenuID`, `OptionID`, `OptionIcon`, `OptionTex
3636
DELETE FROM `creature_template_model` where `CreatureID` = @ENTRY;
3737
INSERT INTO `creature_template_model` (`CreatureID`, `Idx`, `CreatureDisplayID`, `DisplayScale`, `Probability`, `VerifiedBuild`) VALUES (@ENTRY, 0, @MODELID, 1, 1, 12340);
3838

39-
UPDATE `creature_template` SET `npcflag`=1 WHERE `entry`=601072;
39+
UPDATE `creature_template` SET `npcflag`=`npcflag`|1 WHERE `entry`=@ENTRY;

src/morphsummon.cpp

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
33
*/
44

5-
#include "ScriptMgr.h"
6-
#include "Player.h"
7-
#include "Unit.h"
85
#include "Chat.h"
96
#include "Config.h"
107
#include "Pet.h"
11-
#include "ScriptedGossip.h"
8+
#include "Player.h"
129
#include "ScriptedCreature.h"
10+
#include "ScriptedGossip.h"
11+
#include "ScriptMgr.h"
1312
#include "SpellAuras.h"
13+
#include "Unit.h"
1414

1515
std::map<std::string, uint32> warlock_imp;
1616
std::map<std::string, uint32> warlock_voidwalker;
@@ -79,17 +79,18 @@ enum MorphSummonEvents
7979
class MorphSummonPlayerScript : public PlayerScript
8080
{
8181
public:
82-
MorphSummonPlayerScript() : PlayerScript("MorphSummonPlayerScript") {}
82+
MorphSummonPlayerScript() : PlayerScript("MorphSummonPlayerScript", {
83+
PLAYERHOOK_ON_LOGIN,
84+
PLAYERHOOK_ON_AFTER_GUARDIAN_INIT_STATS_FOR_LEVEL
85+
}) {}
8386

84-
void OnLogin(Player* player) override
87+
void OnPlayerLogin(Player* player) override
8588
{
8689
if (morphSummonAnnounce)
87-
{
8890
ChatHandler(player->GetSession()).SendSysMessage("This server is running the |cff4CFF00MorphSummon |rmodule.");
89-
}
9091
}
9192

92-
void OnAfterGuardianInitStatsForLevel(Player* player, Guardian* guardian) override
93+
void OnPlayerAfterGuardianInitStatsForLevel(Player* player, Guardian* guardian) override
9394
{
9495
if (Pet* pet = guardian->ToPet())
9596
{
@@ -126,9 +127,7 @@ class MorphSummonCreatureScript : public CreatureScript
126127
ClearGossipMenuFor(player);
127128

128129
if (action == MORPH_MAIN_MENU)
129-
{
130130
return CreateMainMenu(player, creature);
131-
}
132131

133132
if (action == MORPH_CLOSE_MENU)
134133
{
@@ -137,71 +136,39 @@ class MorphSummonCreatureScript : public CreatureScript
137136
}
138137

139138
if (action >= MORPH_PAGE_START_WARLOCK_IMP && action < MORPH_PAGE_START_WARLOCK_VOIDWALKER)
140-
{
141139
AddGossip(player, action, warlock_imp, MORPH_PAGE_START_WARLOCK_IMP);
142-
}
143140
else if (action >= MORPH_PAGE_START_WARLOCK_VOIDWALKER && action < MORPH_PAGE_START_WARLOCK_SUCCUBUS)
144-
{
145141
AddGossip(player, action, warlock_voidwalker, MORPH_PAGE_START_WARLOCK_VOIDWALKER);
146-
}
147142
else if (action >= MORPH_PAGE_START_WARLOCK_SUCCUBUS && action < MORPH_PAGE_START_WARLOCK_FELHUNTER)
148-
{
149143
AddGossip(player, action, warlock_succubus, MORPH_PAGE_START_WARLOCK_SUCCUBUS);
150-
}
151144
else if (action >= MORPH_PAGE_START_WARLOCK_FELHUNTER && action < MORPH_PAGE_START_WARLOCK_FELGUARD)
152-
{
153145
AddGossip(player, action, warlock_felhunter, MORPH_PAGE_START_WARLOCK_FELHUNTER);
154-
}
155146
else if (action >= MORPH_PAGE_START_WARLOCK_FELGUARD && action < MORPH_PAGE_START_DEATH_KNIGHT_GHOUL)
156-
{
157147
AddGossip(player, action, warlock_felguard, MORPH_PAGE_START_WARLOCK_FELGUARD);
158-
}
159148
else if (action >= MORPH_PAGE_START_DEATH_KNIGHT_GHOUL && action < MORPH_PAGE_START_MAGE_WATER_ELEMENTAL)
160-
{
161149
AddGossip(player, action, death_knight_ghoul, MORPH_PAGE_START_DEATH_KNIGHT_GHOUL);
162-
}
163150
else if (action >= MORPH_PAGE_START_MAGE_WATER_ELEMENTAL && action < MORPH_PAGE_START_FELGUARD_WEAPON)
164-
{
165151
AddGossip(player, action, mage_water_elemental, MORPH_PAGE_START_MAGE_WATER_ELEMENTAL);
166-
}
167152
else if (action >= MORPH_PAGE_START_FELGUARD_WEAPON && action < MORPH_PAGE_MAX)
168-
{
169153
AddGossip(player, action, felguard_weapon, MORPH_PAGE_START_FELGUARD_WEAPON);
170-
}
171154
else if (action >= MORPH_PAGE_MAX)
172155
{
173156
if (sender >= MORPH_PAGE_START_WARLOCK_IMP && sender < MORPH_PAGE_START_WARLOCK_VOIDWALKER)
174-
{
175157
Polymorph(player, action, sender, MORPH_PAGE_START_WARLOCK_IMP, MORPH_PAGE_START_WARLOCK_VOIDWALKER, SUMMON_IMP, warlock_imp, true);
176-
}
177158
else if (sender >= MORPH_PAGE_START_WARLOCK_VOIDWALKER && sender < MORPH_PAGE_START_WARLOCK_SUCCUBUS)
178-
{
179159
Polymorph(player, action, sender, MORPH_PAGE_START_WARLOCK_VOIDWALKER, MORPH_PAGE_START_WARLOCK_SUCCUBUS, SUMMON_VOIDWALKER, warlock_voidwalker, true);
180-
}
181160
else if (sender >= MORPH_PAGE_START_WARLOCK_SUCCUBUS && sender < MORPH_PAGE_START_WARLOCK_FELHUNTER)
182-
{
183161
Polymorph(player, action, sender, MORPH_PAGE_START_WARLOCK_SUCCUBUS, MORPH_PAGE_START_WARLOCK_FELHUNTER, SUMMON_SUCCUBUS, warlock_succubus, true);
184-
}
185162
else if (sender >= MORPH_PAGE_START_WARLOCK_FELHUNTER && sender < MORPH_PAGE_START_WARLOCK_FELGUARD)
186-
{
187163
Polymorph(player, action, sender, MORPH_PAGE_START_WARLOCK_FELHUNTER, MORPH_PAGE_START_WARLOCK_FELGUARD, SUMMON_FELHUNTER, warlock_felhunter, true);
188-
}
189164
else if (sender >= MORPH_PAGE_START_WARLOCK_FELGUARD && sender < MORPH_PAGE_START_DEATH_KNIGHT_GHOUL)
190-
{
191165
Polymorph(player, action, sender, MORPH_PAGE_START_WARLOCK_FELGUARD, MORPH_PAGE_START_DEATH_KNIGHT_GHOUL, SUMMON_FELGUARD, warlock_felguard, true);
192-
}
193166
else if (sender >= MORPH_PAGE_START_DEATH_KNIGHT_GHOUL && sender < MORPH_PAGE_START_MAGE_WATER_ELEMENTAL)
194-
{
195167
Polymorph(player, action, sender, MORPH_PAGE_START_DEATH_KNIGHT_GHOUL, MORPH_PAGE_START_MAGE_WATER_ELEMENTAL, RAISE_DEAD, death_knight_ghoul, true);
196-
}
197168
else if (sender >= MORPH_PAGE_START_MAGE_WATER_ELEMENTAL && sender < MORPH_PAGE_START_FELGUARD_WEAPON)
198-
{
199169
Polymorph(player, action, sender, MORPH_PAGE_START_MAGE_WATER_ELEMENTAL, MORPH_PAGE_START_FELGUARD_WEAPON, SUMMON_WATER_ELEMENTAL, mage_water_elemental, true);
200-
}
201170
else if (sender >= MORPH_PAGE_START_FELGUARD_WEAPON && sender < MORPH_PAGE_MAX)
202-
{
203171
Polymorph(player, action, sender, MORPH_PAGE_START_FELGUARD_WEAPON, MORPH_PAGE_MAX, SUMMON_FELGUARD, felguard_weapon, false);
204-
}
205172
}
206173

207174
SendGossipMenuFor(player, MORPH_GOSSIP_TEXT_CHOICE, creature->GetGUID());
@@ -264,9 +231,7 @@ class MorphSummonCreatureScript : public CreatureScript
264231
if (minion->GetUInt32Value(UNIT_CREATED_BY_SPELL) == SUMMON_WATER_ELEMENTAL)
265232
{
266233
if (!mage_water_elemental.empty())
267-
{
268234
AddGossipItemFor(player, MORPH_GOSSIP_MENU_HELLO, MORPH_GOSSIP_OPTION_POLYMORPH, GOSSIP_SENDER_MAIN, MORPH_PAGE_START_MAGE_WATER_ELEMENTAL);
269-
}
270235
}
271236
}
272237
}
@@ -306,14 +271,10 @@ class MorphSummonCreatureScript : public CreatureScript
306271
AddGossipItemFor(player, MORPH_GOSSIP_MENU_HELLO, MORPH_GOSSIP_OPTION_POLYMORPH, GOSSIP_SENDER_MAIN, MORPH_PAGE_START_WARLOCK_FELGUARD);
307272

308273
if (!felguard_weapon.empty())
309-
{
310274
AddGossipItemFor(player, MORPH_GOSSIP_MENU_HELLO, MORPH_GOSSIP_OPTION_FELGUARD_WEAPON, GOSSIP_SENDER_MAIN, MORPH_PAGE_START_FELGUARD_WEAPON);
311-
}
312275
}
313276
else if (!felguard_weapon.empty())
314-
{
315277
AddGossipItemFor(player, MORPH_GOSSIP_MENU_HELLO, MORPH_GOSSIP_OPTION_FELGUARD_WEAPON, GOSSIP_SENDER_MAIN, MORPH_PAGE_START_FELGUARD_WEAPON);
316-
}
317278
else
318279
sorry = true;
319280
break;
@@ -328,9 +289,7 @@ class MorphSummonCreatureScript : public CreatureScript
328289
}
329290
}
330291
else
331-
{
332292
sorry = true;
333-
}
334293
}
335294

336295
if (sorry)
@@ -374,13 +333,9 @@ class MorphSummonCreatureScript : public CreatureScript
374333
Minion* minion = player->GetFirstMinion();
375334

376335
if (pet != nullptr)
377-
{
378336
petOrMinion = pet;
379-
}
380337
else if (minion != nullptr)
381-
{
382338
petOrMinion = minion;
383-
}
384339

385340
if (petOrMinion != nullptr)
386341
{
@@ -422,7 +377,9 @@ class MorphSummonCreatureScript : public CreatureScript
422377
class MorphSummonWorldScript : public WorldScript
423378
{
424379
public:
425-
MorphSummonWorldScript() : WorldScript("MorphSummonWorldScript") {}
380+
MorphSummonWorldScript() : WorldScript("MorphSummonWorldScript", {
381+
WORLDHOOK_ON_BEFORE_CONFIG_LOAD
382+
}) {}
426383

427384
void OnBeforeConfigLoad(bool /*reload*/) override
428385
{
@@ -484,9 +441,7 @@ class MorphSummonWorldScript : public WorldScript
484441
while (std::getline(modelsStringStream, delimitedValue, ','))
485442
{
486443
if (count % 2 == 0)
487-
{
488444
modelName = delimitedValue;
489-
}
490445
else
491446
{
492447
uint32 modelId = atoi(delimitedValue.c_str());

0 commit comments

Comments
 (0)