@@ -80,26 +80,29 @@ void LoadDatabase()
80
80
81
81
}
82
82
83
- struct TSpellSummary {
83
+ struct TSpellSummary
84
+ {
84
85
uint8 Targets; // set of enum SelectTarget
85
86
uint8 Effects; // set of enum SelectEffect
86
- }extern *SpellSummary;
87
+ } extern *SpellSummary;
87
88
88
89
MANGOS_DLL_EXPORT
89
90
void FreeScriptLibrary ()
90
91
{
91
92
// Free Spell Summary
92
- delete [] SpellSummary;
93
+ delete[] SpellSummary;
93
94
94
95
// 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)
96
97
delete *itr;
97
98
98
- m_scripts. clear () ;
99
+ delete m_scripts;
99
100
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)
101
102
delete itr->second ;
102
103
104
+ delete m_scriptStorage;
105
+
103
106
num_sc_scripts = 0 ;
104
107
SD2Database.HaltDelayThread ();
105
108
}
@@ -139,10 +142,10 @@ void InitScriptLibrary()
139
142
bar.step ();
140
143
outstring_log (" " );
141
144
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 );
144
147
145
- m_scriptStorage. clear ();
148
+ m_scriptStorage = new SDScriptMap ();
146
149
147
150
FillSpellSummary ();
148
151
@@ -151,7 +154,7 @@ void InitScriptLibrary()
151
154
// Check existance scripts for all registered by core script names
152
155
for (uint32 i = 1 ; i < GetScriptIdsCount (); ++i)
153
156
{
154
- if (!m_scripts[i] )
157
+ if (!m_scripts-> at (i) )
155
158
error_log (" SD2: No script found for ScriptName '%s'." , GetScriptName (i));
156
159
}
157
160
@@ -185,7 +188,6 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
185
188
}
186
189
187
190
const StringTextData* pData = pSystemMgr.GetTextData (iTextEntry);
188
-
189
191
if (!pData)
190
192
{
191
193
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)
200
202
if (pData->uiSoundId )
201
203
{
202
204
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
+ }
204
217
else
205
218
error_log (" SD2: DoScriptText entry %i tried to process invalid sound id %u." , iTextEntry, pData->uiSoundId );
206
219
}
@@ -282,7 +295,6 @@ void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map*
282
295
}
283
296
284
297
const StringTextData* pData = pSystemMgr.GetTextData (iTextEntry);
285
-
286
298
if (!pData)
287
299
{
288
300
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*
292
304
debug_log (" SD2: DoOrSimulateScriptTextForMap: text entry=%i, Sound=%u, Type=%u, Language=%u, Emote=%u" ,
293
305
iTextEntry, pData->uiSoundId , pData->uiType , pData->uiLanguage , pData->uiEmote );
294
306
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
+
295
313
if (pData->uiSoundId )
296
314
{
297
315
if (GetSoundEntriesStore ()->LookupEntry (pData->uiSoundId ))
@@ -300,15 +318,10 @@ void DoOrSimulateScriptTextForMap(int32 iTextEntry, uint32 uiCreatureEntry, Map*
300
318
error_log (" SD2: DoOrSimulateScriptTextForMap entry %i tried to process invalid sound id %u." , iTextEntry, pData->uiSoundId );
301
319
}
302
320
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);
312
325
}
313
326
314
327
// *********************************
@@ -318,15 +331,15 @@ void Script::RegisterSelf(bool bReportError)
318
331
{
319
332
if (uint32 id = GetScriptId (Name.c_str ()))
320
333
{
321
- m_scripts[id] = this ;
334
+ m_scripts-> at (id) = this ;
322
335
++num_sc_scripts;
323
336
}
324
337
else
325
338
{
326
339
if (bReportError)
327
340
error_log (" SD2: Script registering but ScriptName %s is not assigned in database. Script will not be used." , Name.c_str ());
328
341
329
- m_scriptStorage. insert (std::make_pair (Name.c_str (), this ));
342
+ m_scriptStorage-> insert (std::make_pair (Name.c_str (), this ));
330
343
}
331
344
}
332
345
@@ -345,7 +358,7 @@ bool GossipHello(Player* pPlayer, Creature* pCreature)
345
358
if (!pCreature)
346
359
return false ;
347
360
348
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
361
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
349
362
350
363
if (!pTempScript || !pTempScript->pGossipHello )
351
364
return false ;
@@ -361,7 +374,7 @@ bool GOGossipHello(Player* pPlayer, GameObject* pGo)
361
374
if (!pGo)
362
375
return false ;
363
376
364
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
377
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
365
378
366
379
if (!pTempScript || !pTempScript->pGossipHelloGO )
367
380
return false ;
@@ -379,7 +392,7 @@ bool GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32
379
392
if (!pCreature)
380
393
return false ;
381
394
382
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
395
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
383
396
384
397
if (!pTempScript || !pTempScript->pGossipSelect )
385
398
return false ;
@@ -399,7 +412,7 @@ bool GOGossipSelect(Player* pPlayer, GameObject* pGo, uint32 uiSender, uint32 ui
399
412
if (!pGo)
400
413
return false ;
401
414
402
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
415
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
403
416
404
417
if (!pTempScript || !pTempScript->pGossipSelectGO )
405
418
return false ;
@@ -417,7 +430,7 @@ bool GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender,
417
430
if (!pCreature)
418
431
return false ;
419
432
420
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
433
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
421
434
422
435
if (!pTempScript || !pTempScript->pGossipSelectWithCode )
423
436
return false ;
@@ -435,7 +448,7 @@ bool GOGossipSelectWithCode(Player* pPlayer, GameObject* pGo, uint32 uiSender, u
435
448
if (!pGo)
436
449
return false ;
437
450
438
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
451
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
439
452
440
453
if (!pTempScript || !pTempScript->pGossipSelectGOWithCode )
441
454
return false ;
@@ -451,7 +464,7 @@ bool QuestAccept(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
451
464
if (!pCreature)
452
465
return false ;
453
466
454
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
467
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
455
468
456
469
if (!pTempScript || !pTempScript->pQuestAcceptNPC )
457
470
return false ;
@@ -467,7 +480,7 @@ bool QuestRewarded(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
467
480
if (!pCreature)
468
481
return false ;
469
482
470
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
483
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
471
484
472
485
if (!pTempScript || !pTempScript->pQuestRewardedNPC )
473
486
return false ;
@@ -480,7 +493,7 @@ bool QuestRewarded(Player* pPlayer, Creature* pCreature, Quest const* pQuest)
480
493
MANGOS_DLL_EXPORT
481
494
uint32 GetNPCDialogStatus (Player* pPlayer, Creature* pCreature)
482
495
{
483
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
496
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
484
497
485
498
if (!pTempScript || !pTempScript->pDialogStatusNPC )
486
499
return 100 ;
@@ -496,7 +509,7 @@ uint32 GetGODialogStatus(Player* pPlayer, GameObject* pGo)
496
509
if (!pGo)
497
510
return false ;
498
511
499
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
512
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
500
513
501
514
if (!pTempScript || !pTempScript->pDialogStatusGO )
502
515
return 100 ;
@@ -512,7 +525,7 @@ bool ItemQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest)
512
525
if (!pItem)
513
526
return false ;
514
527
515
- Script* pTempScript = m_scripts[ pItem->GetProto ()->ScriptId ] ;
528
+ Script* pTempScript = m_scripts-> at ( pItem->GetProto ()->ScriptId ) ;
516
529
517
530
if (!pTempScript || !pTempScript->pQuestAcceptItem )
518
531
return false ;
@@ -528,7 +541,7 @@ bool GOUse(Player* pPlayer, GameObject* pGo)
528
541
if (!pGo)
529
542
return false ;
530
543
531
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
544
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
532
545
533
546
if (!pTempScript || !pTempScript->pGOUse )
534
547
return false ;
@@ -542,7 +555,7 @@ bool GOQuestAccept(Player* pPlayer, GameObject* pGo, const Quest* pQuest)
542
555
if (!pGo)
543
556
return false ;
544
557
545
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
558
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
546
559
547
560
if (!pTempScript || !pTempScript->pQuestAcceptGO )
548
561
return false ;
@@ -558,7 +571,7 @@ bool GOQuestRewarded(Player* pPlayer, GameObject* pGo, Quest const* pQuest)
558
571
if (!pGo)
559
572
return false ;
560
573
561
- Script* pTempScript = m_scripts[ pGo->GetGOInfo ()->ScriptId ] ;
574
+ Script* pTempScript = m_scripts-> at ( pGo->GetGOInfo ()->ScriptId ) ;
562
575
563
576
if (!pTempScript || !pTempScript->pQuestRewardedGO )
564
577
return false ;
@@ -571,7 +584,7 @@ bool GOQuestRewarded(Player* pPlayer, GameObject* pGo, Quest const* pQuest)
571
584
MANGOS_DLL_EXPORT
572
585
bool AreaTrigger (Player* pPlayer, AreaTriggerEntry const * atEntry)
573
586
{
574
- Script* pTempScript = m_scripts[ GetAreaTriggerScriptId (atEntry->id )] ;
587
+ Script* pTempScript = m_scripts-> at ( GetAreaTriggerScriptId (atEntry->id )) ;
575
588
576
589
if (!pTempScript || !pTempScript->pAreaTrigger )
577
590
return false ;
@@ -582,7 +595,7 @@ bool AreaTrigger(Player* pPlayer, AreaTriggerEntry const* atEntry)
582
595
MANGOS_DLL_EXPORT
583
596
bool ProcessEvent (uint32 uiEventId, Object* pSource, Object* pTarget, bool bIsStart)
584
597
{
585
- Script* pTempScript = m_scripts[ GetEventIdScriptId (uiEventId)] ;
598
+ Script* pTempScript = m_scripts-> at ( GetEventIdScriptId (uiEventId)) ;
586
599
587
600
if (!pTempScript || !pTempScript->pProcessEventId )
588
601
return false ;
@@ -597,7 +610,7 @@ CreatureAI* GetCreatureAI(Creature* pCreature)
597
610
if (!pCreature)
598
611
return false ;
599
612
600
- Script* pTempScript = m_scripts[ pCreature->GetScriptId ()] ;
613
+ Script* pTempScript = m_scripts-> at ( pCreature->GetScriptId ()) ;
601
614
602
615
if (!pTempScript || !pTempScript->GetAI )
603
616
return NULL ;
@@ -611,7 +624,7 @@ bool ItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
611
624
if (!pItem)
612
625
return false ;
613
626
614
- Script* pTempScript = m_scripts[ pItem->GetProto ()->ScriptId ] ;
627
+ Script* pTempScript = m_scripts-> at ( pItem->GetProto ()->ScriptId ) ;
615
628
616
629
if (!pTempScript || !pTempScript->pItemUse )
617
630
return false ;
@@ -625,7 +638,7 @@ bool EffectDummyCreature(Unit* pCaster, uint32 spellId, SpellEffectIndex effInde
625
638
if (!pTarget)
626
639
return false ;
627
640
628
- Script* pTempScript = m_scripts[ pTarget->GetScriptId ()] ;
641
+ Script* pTempScript = m_scripts-> at ( pTarget->GetScriptId ()) ;
629
642
630
643
if (!pTempScript || !pTempScript->pEffectDummyNPC )
631
644
return false ;
@@ -639,7 +652,7 @@ bool EffectDummyGameObject(Unit* pCaster, uint32 spellId, SpellEffectIndex effIn
639
652
if (!pTarget)
640
653
return false ;
641
654
642
- Script* pTempScript = m_scripts[ pTarget->GetGOInfo ()->ScriptId ] ;
655
+ Script* pTempScript = m_scripts-> at ( pTarget->GetGOInfo ()->ScriptId ) ;
643
656
644
657
if (!pTempScript || !pTempScript->pEffectDummyGO )
645
658
return false ;
@@ -653,7 +666,7 @@ bool EffectDummyItem(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, I
653
666
if (!pTarget)
654
667
return false ;
655
668
656
- Script* pTempScript = m_scripts[ pTarget->GetProto ()->ScriptId ] ;
669
+ Script* pTempScript = m_scripts-> at ( pTarget->GetProto ()->ScriptId ) ;
657
670
658
671
if (!pTempScript || !pTempScript->pEffectDummyItem )
659
672
return false ;
@@ -664,7 +677,7 @@ bool EffectDummyItem(Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, I
664
677
MANGOS_DLL_EXPORT
665
678
bool AuraDummy (Aura const * pAura, bool bApply)
666
679
{
667
- Script* pTempScript = m_scripts[(( Creature*)pAura->GetTarget ())->GetScriptId ()] ;
680
+ Script* pTempScript = m_scripts-> at ((( Creature*)pAura->GetTarget ())->GetScriptId ()) ;
668
681
669
682
if (!pTempScript || !pTempScript->pEffectAuraDummy )
670
683
return false ;
@@ -675,7 +688,7 @@ bool AuraDummy(Aura const* pAura, bool bApply)
675
688
MANGOS_DLL_EXPORT
676
689
InstanceData* CreateInstanceData (Map* pMap)
677
690
{
678
- Script* pTempScript = m_scripts[ pMap->GetScriptId ()] ;
691
+ Script* pTempScript = m_scripts-> at ( pMap->GetScriptId ()) ;
679
692
680
693
if (!pTempScript || !pTempScript->GetInstanceData )
681
694
return NULL ;
@@ -685,8 +698,8 @@ InstanceData* CreateInstanceData(Map* pMap)
685
698
686
699
Script* GetScriptByName (std::string scriptName)
687
700
{
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 ())
690
703
return itr->second ;
691
704
else
692
705
return NULL ;
0 commit comments