Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit 562edfd

Browse files
author
philipp.dallig
committed
other stuff
1 parent 32632d4 commit 562edfd

File tree

92 files changed

+8443
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+8443
-72
lines changed

ScriptMgr.cpp

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,29 @@ void LoadDatabase()
8080

8181
}
8282

83-
struct TSpellSummary {
83+
struct TSpellSummary
84+
{
8485
uint8 Targets; // set of enum SelectTarget
8586
uint8 Effects; // set of enum SelectEffect
86-
}extern *SpellSummary;
87+
} extern *SpellSummary;
8788

8889
MANGOS_DLL_EXPORT
8990
void FreeScriptLibrary()
9091
{
9192
// Free Spell Summary
92-
delete []SpellSummary;
93+
delete[] SpellSummary;
9394

9495
// Free resources before library unload
95-
for (SDScriptVec::const_iterator itr = m_scripts.begin(); itr != m_scripts.end(); ++itr)
96+
for (SDScriptVec::const_iterator itr = m_scripts->begin(); itr != m_scripts->end(); ++itr)
9697
delete *itr;
9798

98-
m_scripts.clear();
99+
delete m_scripts;
99100

100-
for (std::map<std::string, Script*>::iterator itr = m_scriptStorage.begin(); itr != m_scriptStorage.end(); ++itr)
101+
for (SDScriptMap::const_iterator itr = m_scriptStorage->begin(); itr != m_scriptStorage->end(); ++itr)
101102
delete itr->second;
102103

104+
delete m_scriptStorage;
105+
103106
num_sc_scripts = 0;
104107
SD2Database.HaltDelayThread();
105108
}
@@ -139,10 +142,10 @@ void InitScriptLibrary()
139142
bar.step();
140143
outstring_log("");
141144

142-
// Resize script ids to needed ammount of assigned ScriptNames (from core)
143-
m_scripts.resize(GetScriptIdsCount(), NULL);
145+
// Initialize script ids to needed ammount of assigned ScriptNames (from core)
146+
m_scripts = new SDScriptVec(GetScriptIdsCount(), NULL);
144147

145-
m_scriptStorage.clear();
148+
m_scriptStorage = new SDScriptMap();
146149

147150
FillSpellSummary();
148151

@@ -151,7 +154,7 @@ void InitScriptLibrary()
151154
// Check existance scripts for all registered by core script names
152155
for (uint32 i = 1; i < GetScriptIdsCount(); ++i)
153156
{
154-
if (!m_scripts[i])
157+
if (!m_scripts->at(i))
155158
error_log("SD2: No script found for ScriptName '%s'.", GetScriptName(i));
156159
}
157160

@@ -185,7 +188,6 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
185188
}
186189

187190
const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
188-
189191
if (!pData)
190192
{
191193
error_log("SD2: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.",
@@ -200,7 +202,18 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
200202
if (pData->uiSoundId)
201203
{
202204
if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
203-
pSource->PlayDirectSound(pData->uiSoundId);
205+
{
206+
if (pData->uiType == CHAT_TYPE_ZONE_YELL)
207+
pSource->GetMap()->PlayDirectSoundToMap(pData->uiSoundId, pSource->GetZoneId());
208+
else if (pData->uiType == CHAT_TYPE_WHISPER || pData->uiType == CHAT_TYPE_BOSS_WHISPER)
209+
{
210+
// An error will be displayed for the text
211+
if (pTarget && pTarget->GetTypeId() == TYPEID_PLAYER)
212+
pSource->PlayDirectSound(pData->uiSoundId, (Player*)pTarget);
213+
}
214+
else
215+
pSource->PlayDirectSound(pData->uiSoundId);
216+
}
204217
else
205218
error_log("SD2: DoScriptText entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
206219
}
@@ -282,7 +295,6 @@ void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map*
282295
}
283296

284297
const StringTextData* pData = pSystemMgr.GetTextData(iTextEntry);
285-
286298
if (!pData)
287299
{
288300
error_log("SD2: DoOrSimulateScriptTextForMap with source entry %u for map %u could not find text entry %i.", uiCreatureEntry, pMap->GetId(), iTextEntry);
@@ -292,6 +304,12 @@ void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map*
292304
debug_log("SD2: DoOrSimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u",
293305
iTextEntry, pData->uiSoundId, pData->uiType, pData->uiLanguage, pData->uiEmote);
294306

307+
if (pData->uiType != CHAT_TYPE_ZONE_YELL)
308+
{
309+
error_log("SD2: DoSimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
310+
return;
311+
}
312+
295313
if (pData->uiSoundId)
296314
{
297315
if (GetSoundEntriesStore()->LookupEntry(pData->uiSoundId))
@@ -300,15 +318,10 @@ void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map*
300318
error_log("SD2: DoOrSimulateScriptTextForMap entry %i tried to process invalid sound id %u.", iTextEntry, pData->uiSoundId);
301319
}
302320

303-
if (pData->uiType == CHAT_TYPE_ZONE_YELL)
304-
{
305-
if (pCreatureSource) // If provided pointer for sayer, use direct version
306-
pMap->MonsterYellToMap(pCreatureSource->GetObjectGuid(), iTextEntry, pData->uiLanguage, pTarget);
307-
else // Simulate yell
308-
pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget);
309-
}
310-
else
311-
error_log("SD2: DoSimulateScriptTextForMap entry %i has not supported chat type %u.", iTextEntry, pData->uiType);
321+
if (pCreatureSource) // If provided pointer for sayer, use direct version
322+
pMap->MonsterYellToMap(pCreatureSource->GetObjectGuid(), iTextEntry, pData->uiLanguage, pTarget);
323+
else // Simulate yell
324+
pMap->MonsterYellToMap(pInfo, iTextEntry, pData->uiLanguage, pTarget);
312325
}
313326

314327
//*********************************
@@ -318,15 +331,15 @@ void Script::RegisterSelf(bool bReportError)
318331
{
319332
if (uint32 id = GetScriptId(Name.c_str()))
320333
{
321-
m_scripts[id] = this;
334+
m_scripts->at(id) = this;
322335
++num_sc_scripts;
323336
}
324337
else
325338
{
326339
if (bReportError)
327340
error_log("SD2: Script registering but ScriptName %s is not assigned in database. Script will not be used.", Name.c_str());
328341

329-
m_scriptStorage.insert(std::make_pair(Name.c_str(), this));
342+
m_scriptStorage->insert(std::make_pair(Name.c_str(), this));
330343
}
331344
}
332345

@@ -345,7 +358,7 @@ bool GossipHello(Player* pPlayer, Creature* pCreature)
345358
if (!pCreature)
346359
return false;
347360

348-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
361+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
349362

350363
if (!pTempScript || !pTempScript->pGossipHello)
351364
return false;
@@ -361,7 +374,7 @@ bool GOGossipHello(Player* pPlayer, GameObject* pGo)
361374
if (!pGo)
362375
return false;
363376

364-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
377+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
365378

366379
if (!pTempScript || !pTempScript->pGossipHelloGO)
367380
return false;
@@ -379,7 +392,7 @@ bool GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32
379392
if (!pCreature)
380393
return false;
381394

382-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
395+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
383396

384397
if (!pTempScript || !pTempScript->pGossipSelect)
385398
return false;
@@ -399,7 +412,7 @@ bool GOGossipSelect(Player* pPlayer, GameObject* pGo, uint32 uiSender, uint32 ui
399412
if (!pGo)
400413
return false;
401414

402-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
415+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
403416

404417
if (!pTempScript || !pTempScript->pGossipSelectGO)
405418
return false;
@@ -417,7 +430,7 @@ bool GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender,
417430
if (!pCreature)
418431
return false;
419432

420-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
433+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
421434

422435
if (!pTempScript || !pTempScript->pGossipSelectWithCode)
423436
return false;
@@ -435,7 +448,7 @@ bool GOGossipSelectWithCode(Player* pPlayer, GameObject* pGo, uint32 uiSender, u
435448
if (!pGo)
436449
return false;
437450

438-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
451+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
439452

440453
if (!pTempScript || !pTempScript->pGossipSelectGOWithCode)
441454
return false;
@@ -451,7 +464,7 @@ bool QuestAccept(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
451464
if (!pCreature)
452465
return false;
453466

454-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
467+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
455468

456469
if (!pTempScript || !pTempScript->pQuestAcceptNPC)
457470
return false;
@@ -467,7 +480,7 @@ bool QuestRewarded(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
467480
if (!pCreature)
468481
return false;
469482

470-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
483+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
471484

472485
if (!pTempScript || !pTempScript->pQuestRewardedNPC)
473486
return false;
@@ -480,7 +493,7 @@ bool QuestRewarded(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
480493
MANGOS_DLL_EXPORT
481494
uint32 GetNPCDialogStatus(Player* pPlayer, Creature* pCreature)
482495
{
483-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
496+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
484497

485498
if (!pTempScript || !pTempScript->pDialogStatusNPC)
486499
return 100;
@@ -496,7 +509,7 @@ uint32 GetGODialogStatus(Player* pPlayer, GameObject* pGo)
496509
if (!pGo)
497510
return false;
498511

499-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
512+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
500513

501514
if (!pTempScript || !pTempScript->pDialogStatusGO)
502515
return 100;
@@ -512,7 +525,7 @@ bool ItemQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest)
512525
if (!pItem)
513526
return false;
514527

515-
Script* pTempScript = m_scripts[pItem->GetProto()->ScriptId];
528+
Script* pTempScript = m_scripts->at(pItem->GetProto()->ScriptId);
516529

517530
if (!pTempScript || !pTempScript->pQuestAcceptItem)
518531
return false;
@@ -528,7 +541,7 @@ bool GOUse(Player* pPlayer, GameObject* pGo)
528541
if (!pGo)
529542
return false;
530543

531-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
544+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
532545

533546
if (!pTempScript || !pTempScript->pGOUse)
534547
return false;
@@ -542,7 +555,7 @@ bool GOQuestAccept(Player* pPlayer, GameObject* pGo, const Quest* pQuest)
542555
if (!pGo)
543556
return false;
544557

545-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
558+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
546559

547560
if (!pTempScript || !pTempScript->pQuestAcceptGO)
548561
return false;
@@ -558,7 +571,7 @@ bool GOQuestRewarded(Player* pPlayer, GameObject* pGo, Quest const* pQuest)
558571
if (!pGo)
559572
return false;
560573

561-
Script* pTempScript = m_scripts[pGo->GetGOInfo()->ScriptId];
574+
Script* pTempScript = m_scripts->at(pGo->GetGOInfo()->ScriptId);
562575

563576
if (!pTempScript || !pTempScript->pQuestRewardedGO)
564577
return false;
@@ -571,7 +584,7 @@ bool GOQuestRewarded(Player* pPlayer, GameObject* pGo, Quest const* pQuest)
571584
MANGOS_DLL_EXPORT
572585
bool AreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry)
573586
{
574-
Script* pTempScript = m_scripts[GetAreaTriggerScriptId(atEntry->id)];
587+
Script* pTempScript = m_scripts->at(GetAreaTriggerScriptId(atEntry->id));
575588

576589
if (!pTempScript || !pTempScript->pAreaTrigger)
577590
return false;
@@ -582,7 +595,7 @@ bool AreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry)
582595
MANGOS_DLL_EXPORT
583596
bool ProcessEvent(uint32 uiEventId, Object* pSource, Object* pTarget, bool bIsStart)
584597
{
585-
Script* pTempScript = m_scripts[GetEventIdScriptId(uiEventId)];
598+
Script* pTempScript = m_scripts->at(GetEventIdScriptId(uiEventId));
586599

587600
if (!pTempScript || !pTempScript->pProcessEventId)
588601
return false;
@@ -597,7 +610,7 @@ CreatureAI* GetCreatureAI(Creature* pCreature)
597610
if (!pCreature)
598611
return false;
599612

600-
Script* pTempScript = m_scripts[pCreature->GetScriptId()];
613+
Script* pTempScript = m_scripts->at(pCreature->GetScriptId());
601614

602615
if (!pTempScript || !pTempScript->GetAI)
603616
return NULL;
@@ -611,7 +624,7 @@ bool ItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
611624
if (!pItem)
612625
return false;
613626

614-
Script* pTempScript = m_scripts[pItem->GetProto()->ScriptId];
627+
Script* pTempScript = m_scripts->at(pItem->GetProto()->ScriptId);
615628

616629
if (!pTempScript || !pTempScript->pItemUse)
617630
return false;
@@ -625,7 +638,7 @@ bool EffectDummyCreature(Unit* pCaster, uint32 spellId, SpellEffectIndex effInde
625638
if (!pTarget)
626639
return false;
627640

628-
Script* pTempScript = m_scripts[pTarget->GetScriptId()];
641+
Script* pTempScript = m_scripts->at(pTarget->GetScriptId());
629642

630643
if (!pTempScript || !pTempScript->pEffectDummyNPC)
631644
return false;
@@ -639,7 +652,7 @@ bool EffectDummyGameObject(Unit* pCaster, uint32 spellId, SpellEffectIndex effIn
639652
if (!pTarget)
640653
return false;
641654

642-
Script* pTempScript = m_scripts[pTarget->GetGOInfo()->ScriptId];
655+
Script* pTempScript = m_scripts->at(pTarget->GetGOInfo()->ScriptId);
643656

644657
if (!pTempScript || !pTempScript->pEffectDummyGO)
645658
return false;
@@ -653,7 +666,7 @@ bool EffectDummyItem(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, I
653666
if (!pTarget)
654667
return false;
655668

656-
Script* pTempScript = m_scripts[pTarget->GetProto()->ScriptId];
669+
Script* pTempScript = m_scripts->at(pTarget->GetProto()->ScriptId);
657670

658671
if (!pTempScript || !pTempScript->pEffectDummyItem)
659672
return false;
@@ -664,7 +677,7 @@ bool EffectDummyItem(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, I
664677
MANGOS_DLL_EXPORT
665678
bool AuraDummy(Aura const* pAura, bool bApply)
666679
{
667-
Script* pTempScript = m_scripts[((Creature*)pAura->GetTarget())->GetScriptId()];
680+
Script* pTempScript = m_scripts->at(((Creature*)pAura->GetTarget())->GetScriptId());
668681

669682
if (!pTempScript || !pTempScript->pEffectAuraDummy)
670683
return false;
@@ -675,7 +688,7 @@ bool AuraDummy(Aura const* pAura, bool bApply)
675688
MANGOS_DLL_EXPORT
676689
InstanceData* CreateInstanceData(Map* pMap)
677690
{
678-
Script* pTempScript = m_scripts[pMap->GetScriptId()];
691+
Script* pTempScript = m_scripts->at(pMap->GetScriptId());
679692

680693
if (!pTempScript || !pTempScript->GetInstanceData)
681694
return NULL;
@@ -685,8 +698,8 @@ InstanceData* CreateInstanceData(Map* pMap)
685698

686699
Script* GetScriptByName(std::string scriptName)
687700
{
688-
std::map<std::string, Script*>::const_iterator itr = m_scriptStorage.find(scriptName);
689-
if (itr != m_scriptStorage.end())
701+
SDScriptMap::const_iterator itr = m_scriptStorage->find(scriptName);
702+
if (itr != m_scriptStorage->end())
690703
return itr->second;
691704
else
692705
return NULL;

scripts/northrend/ulduar/ulduar/boss_vezax.cpp renamed to scripts/northrend/ulduar/ulduar/boss_general_vezax.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,4 @@ void AddSC_boss_vezax()
426426
newscript->Name = "mob_saronite_vapor";
427427
newscript->GetAI = &GetAI_mob_saronite_vapor;
428428
newscript->RegisterSelf();
429-
}
429+
}

scripts/northrend/utgarde_keep/utgarde_keep/utgarde_keep.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ CreatureAI* GetAI_mob_dragonflayer_forge_master(Creature* pCreature)
149149

150150
void AddSC_utgarde_keep()
151151
{
152-
Script *newscript;
152+
Script* pNewscript;
153153

154-
newscript = new Script;
155-
newscript->Name = "mob_dragonflayer_forge_master";
156-
newscript->GetAI = &GetAI_mob_dragonflayer_forge_master;
157-
newscript->RegisterSelf();
154+
pNewscript = new Script;
155+
pNewscript->Name = "mob_dragonflayer_forge_master";
156+
pNewscript->GetAI = &GetAI_mob_dragonflayer_forge_master;
157+
pNewscript->RegisterSelf();
158158
}

0 commit comments

Comments
 (0)