12
12
#include " ../system/ScriptLoader.h"
13
13
#include " ../system/system.h"
14
14
#include " ../../../game/ScriptMgr.h"
15
+ #include " World.h"
15
16
16
17
typedef std::vector<Script*> SDScriptVec;
17
18
int num_sc_scripts;
18
19
SDScriptVec m_scripts;
19
20
20
21
Config SD2Config;
21
22
23
+ /* *********************************************************************
24
+ +additions for windows compiler
25
+ **********************************************************************/
26
+ template <> bool MaNGOS::Singleton<World>::si_destroyed;
27
+ template <> bool MaNGOS::Singleton<ObjectMgr>::si_destroyed;
28
+ template <> World *MaNGOS::Singleton<World>::si_instance;
29
+ World::World ()
30
+ {
31
+ }
32
+ World::~World ()
33
+ {
34
+ }
35
+ ObjectMgr::~ObjectMgr ()
36
+ {
37
+ }
38
+ /* **********************************************************************/
39
+
22
40
QueryResult* strSD2Pquery (char * str)
23
41
{
24
42
return SD2Database.Query (str);
@@ -253,6 +271,9 @@ char const* GetScriptLibraryVersion()
253
271
MANGOS_DLL_EXPORT
254
272
bool GossipHello (Player* pPlayer, Creature* pCreature)
255
273
{
274
+ if (!pCreature)
275
+ return false ;
276
+
256
277
Script *tmpscript = m_scripts[pCreature->GetScriptId ()];
257
278
258
279
if (!tmpscript || !tmpscript->pGossipHello )
@@ -266,6 +287,9 @@ bool GossipHello(Player* pPlayer, Creature* pCreature)
266
287
MANGOS_DLL_EXPORT
267
288
bool GOGossipHello (Player *pPlayer, GameObject *pGo)
268
289
{
290
+ if (!pGo)
291
+ return false ;
292
+
269
293
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
270
294
271
295
if (!tmpscript || !tmpscript->pGossipHelloGO )
@@ -281,6 +305,9 @@ bool GossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32
281
305
{
282
306
debug_log (" SD2: Gossip selection, sender: %u, action: %u" , uiSender, uiAction);
283
307
308
+ if (!pCreature)
309
+ return false ;
310
+
284
311
Script *tmpscript = m_scripts[pCreature->GetScriptId ()];
285
312
286
313
if (!tmpscript || !tmpscript->pGossipSelect )
@@ -298,6 +325,9 @@ bool GOGossipSelect(Player *pPlayer, GameObject *pGo, uint32 sender, uint32 acti
298
325
{
299
326
debug_log (" SD2: GO Gossip selection, sender: %u, action: %u" , sender, action);
300
327
328
+ if (!pGo)
329
+ return false ;
330
+
301
331
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
302
332
303
333
if (!tmpscript || !tmpscript->pGossipSelectGO )
@@ -313,6 +343,9 @@ bool GossipSelectWithCode(Player* pPlayer, Creature* pCreature, uint32 uiSender,
313
343
{
314
344
debug_log (" SD2: Gossip selection with code, sender: %u, action: %u" , uiSender, uiAction);
315
345
346
+ if (!pCreature)
347
+ return false ;
348
+
316
349
Script *tmpscript = m_scripts[pCreature->GetScriptId ()];
317
350
318
351
if (!tmpscript || !tmpscript->pGossipSelectWithCode )
@@ -328,6 +361,9 @@ bool GOGossipSelectWithCode(Player *pPlayer, GameObject *pGo, uint32 sender, uin
328
361
{
329
362
debug_log (" SD2: GO Gossip selection with code, sender: %u, action: %u" , sender, action);
330
363
364
+ if (!pGo)
365
+ return false ;
366
+
331
367
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
332
368
333
369
if (!tmpscript || !tmpscript->pGossipSelectGOWithCode )
@@ -341,6 +377,9 @@ bool GOGossipSelectWithCode(Player *pPlayer, GameObject *pGo, uint32 sender, uin
341
377
MANGOS_DLL_EXPORT
342
378
bool QuestAccept (Player* pPlayer, Creature* pCreature, const Quest* pQuest)
343
379
{
380
+ if (!pCreature)
381
+ return false ;
382
+
344
383
Script *tmpscript = m_scripts[pCreature->GetScriptId ()];
345
384
346
385
if (!tmpscript || !tmpscript->pQuestAcceptNPC )
@@ -354,6 +393,9 @@ bool QuestAccept(Player* pPlayer, Creature* pCreature, const Quest* pQuest)
354
393
MANGOS_DLL_EXPORT
355
394
bool QuestRewarded (Player* pPlayer, Creature* pCreature, Quest const * pQuest)
356
395
{
396
+ if (!pCreature)
397
+ return false ;
398
+
357
399
Script *tmpscript = m_scripts[pCreature->GetScriptId ()];
358
400
359
401
if (!tmpscript || !tmpscript->pQuestRewardedNPC )
@@ -380,6 +422,9 @@ uint32 GetNPCDialogStatus(Player* pPlayer, Creature* pCreature)
380
422
MANGOS_DLL_EXPORT
381
423
uint32 GetGODialogStatus (Player* pPlayer, GameObject* pGo)
382
424
{
425
+ if (!pGo)
426
+ return false ;
427
+
383
428
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
384
429
385
430
if (!tmpscript || !tmpscript->pDialogStatusGO )
@@ -393,6 +438,9 @@ uint32 GetGODialogStatus(Player* pPlayer, GameObject* pGo)
393
438
MANGOS_DLL_EXPORT
394
439
bool ItemQuestAccept (Player* pPlayer, Item* pItem, Quest const * pQuest)
395
440
{
441
+ if (!pItem)
442
+ return false ;
443
+
396
444
Script *tmpscript = m_scripts[pItem->GetProto ()->ScriptId ];
397
445
398
446
if (!tmpscript || !tmpscript->pQuestAcceptItem )
@@ -406,6 +454,9 @@ bool ItemQuestAccept(Player* pPlayer, Item* pItem, Quest const* pQuest)
406
454
MANGOS_DLL_EXPORT
407
455
bool GOUse (Player* pPlayer, GameObject* pGo)
408
456
{
457
+ if (!pGo)
458
+ return false ;
459
+
409
460
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
410
461
411
462
if (!tmpscript || !tmpscript->pGOUse )
@@ -417,6 +468,9 @@ bool GOUse(Player* pPlayer, GameObject* pGo)
417
468
MANGOS_DLL_EXPORT
418
469
bool GOQuestAccept (Player* pPlayer, GameObject* pGo, const Quest* pQuest)
419
470
{
471
+ if (!pGo)
472
+ return false ;
473
+
420
474
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
421
475
422
476
if (!tmpscript || !tmpscript->pQuestAcceptGO )
@@ -430,6 +484,9 @@ bool GOQuestAccept(Player* pPlayer, GameObject* pGo, const Quest* pQuest)
430
484
MANGOS_DLL_EXPORT
431
485
bool GOQuestRewarded (Player* pPlayer, GameObject* pGo, Quest const * pQuest)
432
486
{
487
+ if (!pGo)
488
+ return false ;
489
+
433
490
Script *tmpscript = m_scripts[pGo->GetGOInfo ()->ScriptId ];
434
491
435
492
if (!tmpscript || !tmpscript->pQuestRewardedGO )
@@ -466,6 +523,9 @@ bool ProcessEvent(uint32 uiEventId, Object* pSource, Object* pTarget, bool bIsSt
466
523
MANGOS_DLL_EXPORT
467
524
CreatureAI* GetCreatureAI (Creature* pCreature)
468
525
{
526
+ if (!pCreature)
527
+ return false ;
528
+
469
529
Script *tmpscript = m_scripts[pCreature->GetScriptId ()];
470
530
471
531
if (!tmpscript || !tmpscript->GetAI )
@@ -477,6 +537,9 @@ CreatureAI* GetCreatureAI(Creature* pCreature)
477
537
MANGOS_DLL_EXPORT
478
538
bool ItemUse (Player* pPlayer, Item* pItem, SpellCastTargets const & targets)
479
539
{
540
+ if (!pItem)
541
+ return false ;
542
+
480
543
Script *tmpscript = m_scripts[pItem->GetProto ()->ScriptId ];
481
544
482
545
if (!tmpscript || !tmpscript->pItemUse )
@@ -488,6 +551,9 @@ bool ItemUse(Player* pPlayer, Item* pItem, SpellCastTargets const& targets)
488
551
MANGOS_DLL_EXPORT
489
552
bool EffectDummyCreature (Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Creature* pTarget)
490
553
{
554
+ if (!pTarget)
555
+ return false ;
556
+
491
557
Script *tmpscript = m_scripts[pTarget->GetScriptId ()];
492
558
493
559
if (!tmpscript || !tmpscript->pEffectDummyNPC )
@@ -499,6 +565,9 @@ bool EffectDummyCreature(Unit* pCaster, uint32 spellId, SpellEffectIndex effInde
499
565
MANGOS_DLL_EXPORT
500
566
bool EffectDummyGameObject (Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, GameObject* pTarget)
501
567
{
568
+ if (!pTarget)
569
+ return false ;
570
+
502
571
Script *tmpscript = m_scripts[pTarget->GetGOInfo ()->ScriptId ];
503
572
504
573
if (!tmpscript || !tmpscript->pEffectDummyGO )
@@ -510,6 +579,9 @@ bool EffectDummyGameObject(Unit* pCaster, uint32 spellId, SpellEffectIndex effIn
510
579
MANGOS_DLL_EXPORT
511
580
bool EffectDummyItem (Unit* pCaster, uint32 spellId, SpellEffectIndex effIndex, Item* pTarget)
512
581
{
582
+ if (!pTarget)
583
+ return false ;
584
+
513
585
Script *tmpscript = m_scripts[pTarget->GetProto ()->ScriptId ];
514
586
515
587
if (!tmpscript || !tmpscript->pEffectDummyItem )
0 commit comments