PDA

View Full Version : [SOLVED] Problem with custom WorldScript event causing core to crash



slp13at420
09-25-2016, 04:05 PM
So I Cloned a fresh copy of -> https://github.com/ElunaLuaEngine/ElunaTrinityWotlk
TrinityCore rev. da3b1486661f+ 2016-09-21

I added 1 custom script. no custom edits.
Then started receiving errors as posted in this thread -> http://emudevs.com/showthread.php/5900-Error-in-Compile-Scripts-in-the-last-trinityCore
So I updated all the Gossip Methods as Tommy did with his tut's and then the errors cleared and the project compiled complete with 0 errors.

I startup the world and it updates the DB fine. gets to the very end and even belches out:



World initialized in 0 minutes 22 seconds
TrinityCore rev. da3b1486661f+ 2016-09-21 22:49:05 +0300 (master branch) (Win32, Release, Static) (worldserver-daemon) ready...



But then it crashes with this posted to the console:



ScriptMgr.cpp:922 in SpecializedScriptRegistry(class WorldScript,0)::AddScript ASSERTION FAILED:
!sScriptMgr->GetCurrentScriptContext().empty() Tried to register a script without being in a valid script context!



So my custom script has 2 WorldScript's so I `remarked` them out and recompiled and restarted fine. this time no error like above. so with trial and error I narrowed it down to a WorldScript Event block:



class GGW_RankTimer : public WorldScript
{
public:
GGW_RankTimer() : WorldScript("GGW_RankTimer")
{
events.ScheduleEvent(1, GUILDWARZ_RANKING_TIMER);
};

void OnUpdate(uint32 diff) override
{
events.Update(diff);

uint8 id = events.ExecuteEvent();

if (rank_binary_ticker == true)
rank_binary_ticker = false;
else
{
switch (id)
{
case 1:
events.CancelEvent(1);
CreateRankList();
new GGW_RankTimer();
rank_binary_ticker = true;
break;
};
};
};

EventMap events;
};



I narrowed it down to this event causing the crash:



void OnUpdate(uint32 diff) override
{
events.Update(diff);

uint8 id = events.ExecuteEvent();

if (rank_binary_ticker == true)
rank_binary_ticker = false;
else
{
switch (id)
{
case 1:
events.CancelEvent(1);
CreateRankList();
new GGW_RankTimer();
rank_binary_ticker = true;
break;
};
};
};



i'm just not finding anything with a standalone timed event like this to compare to.
any ideas?

Rochet2
09-25-2016, 05:33 PM
new GGW_RankTimer();
This is what crashes.
Why do you do this?

If you need to call events.ScheduleEvent(1, GUILDWARZ_RANKING_TIMER);
again, then make a function and call that in the constructor and in where you need to call it again.

slp13at420
09-25-2016, 05:59 PM
new GGW_RankTimer();
This is what crashes.
Why do you do this?

If you need to call events.ScheduleEvent(1, GUILDWARZ_RANKING_TIMER);
again, then make a function and call that in the constructor and in where you need to call it again.

ugh :doh: lol yea tnx good eye , dunno what I was thinking there lol



if (GUILDWARZ_RANK_TYPE < 2) { events.ScheduleEvent(1, GUILDWARZ_RANKING_TIMER); };


and then I fixed the error by re adding `#include "ScriptMgr.h"` :doh: