Agneese-Saini / SA-MP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fader.inc AOB

samp-pinch opened this issue · comments

Crashdetect:
https://pastebin.com/qiMCJwsw

Code:
safe-zones.inc:

hook OnPlayerEnterDynArea(playerid, STREAMER_TAG_AREA:areaid)
{
	if(areaid == sZoneSpawn)
		PlayerNotifyShow(playerid, "You entered safe zone (Spawn).");

	return Y_HOOKS_CONTINUE_RETURN_1;
}

hook OnPlayerLeaveDynArea(playerid, STREAMER_TAG_AREA:areaid)
{
	if(areaid == sZoneSpawn)
		PlayerNotifyShow(playerid, "You left safe zone (Spawn).");

	return Y_HOOKS_CONTINUE_RETURN_1;
}

notify inc:

PlayerNotifyShow(playerid, const text[])
{
	if(strlen(text) >= 34) return err("Expected input shorter than 34 chars but got longer!", _s("Text", text), _i("Extra chars", strlen(text) - 34 ));
	
	PlayerTextDrawStopBoxFade(playerid, PTD_NOTIFY[playerid][0]);
	PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][1]);
	PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][2]);

	PlayerTextDrawHide(playerid, PTD_NOTIFY[playerid][0]);
	PlayerTextDrawHide(playerid, PTD_NOTIFY[playerid][1]);
	PlayerTextDrawHide(playerid, PTD_NOTIFY[playerid][2]);

	PlayerTextDrawShow(playerid, PTD_NOTIFY[playerid][0]);
	PlayerTextDrawShow(playerid, PTD_NOTIFY[playerid][1]);
	PlayerTextDrawShow(playerid, PTD_NOTIFY[playerid][2]);

	PlayerTextDrawSetString(playerid, PTD_NOTIFY[playerid][1], text);

	PlayerTextDrawBoxFade(playerid, PTD_NOTIFY[playerid][0], 0x00000050, 0x00000000, 2, 50);

	PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][1], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);

	PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][2], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);
	
	return 1;
}

I even removed some YSF and other validity checks and still get this,,
This is 327 from fader.inc:
textDrawFader[playerid][idx][TEXTDRAW_FADE_VALID] = true;
https://github.com/Agneese-Saini/SA-MP/blob/master/pawno/include/fader.inc#L327

Just to add:
When I add some checks I still get same error but for example one or two time it is executed properly than same Backtrace...
Here is what I tried for example:

if(IsPlayerTextDrawVisible(playerid, PTD_NOTIFY[playerid][2]))
	{
		print("visible");
		PlayerTextDrawStopBoxFade(playerid, PTD_NOTIFY[playerid][0]);
		PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][1]);
		PlayerTextDrawStopFade(playerid, PTD_NOTIFY[playerid][2]);
	}
	else
	{
		print("else");
		PlayerTextDrawSetString(playerid, PTD_NOTIFY[playerid][1], text);

		PlayerTextDrawBoxFade(playerid, PTD_NOTIFY[playerid][0], 0x00000050, 0x00000000, 2, 50);

		PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][1], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);

		PlayerTextDrawFade(playerid, PTD_NOTIFY[playerid][2], 0xFFFFFFFF, 0xFFFFFF00, 2, 50);
	}```

I traced the bug and aperrantly there is a fcking infinite loop when I started fading the PTD_NOTIFY[playerid][1]

Internal_StopFade called billions of times without a reason

Fixed two bugs, I'll open PR