• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Problem with custom WorldScript event causing core to crash

Status
Not open for further replies.

slp13at420

Mad Scientist
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 [MENTION=1]Tommy[/MENTION] 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:
Code:
[COLOR="#808080"]
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;
};
[/COLOR]

I narrowed it down to this event causing the crash:
Code:
[COLOR="#808080"]
	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;
			};
		};
	};
[/COLOR]

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

Rochet2

Moderator / Eluna Dev
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

Mad Scientist
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
Code:
[COLOR="#808080"]
if (GUILDWARZ_RANK_TYPE < 2) { events.ScheduleEvent(1, GUILDWARZ_RANKING_TIMER); };
[/COLOR]
and then I fixed the error by re adding `#include "ScriptMgr.h"` :doh:
 
Status
Not open for further replies.
Top