[debug] Run time error 3: "Stack/heap collision (insufficient stack size)
#3

Quote:
Originally Posted by Yashas
Посмотреть сообщение
Its your recurrsive function that is causing the problem.

Each time a function is called, some information is pushed onto the stack. Your function calls itself so many times that your stack size increases to such an extent that it collides with the heap. The heap and stack share the same memory in your RAM and they run in opposite directions.

The problem is that your SpectateNext is an infinite loop.

Код:
function SpectateNext(playerid)
{
    new bool:fl;
	foreach(new i:Player) if(PInfo[i][pInDerby] && i > PInfo[playerid][pSpectateID])
	{
	    new tdstring[85];
	    fl = true;
		PInfo[playerid][pSpectateID] = i;
		format(tdstring, sizeof(tdstring), "~<~ ~g~~h~Spectate: ~w~%s ~>~", GetName(PInfo[playerid][pSpectateID]));
		PlayerTextDrawSetString(playerid, PInfo[playerid][pSpectateTD], tdstring);
		PlayerSpectateVehicle(playerid, GetPlayerVehicleID(i));
		break;
	}
	if(!fl)
	{
	    PInfo[playerid][pSpectateID] = -1;
	    SpectateNext(playerid);
	}
	return 1;
}
The issue is here
Код:
 i > PInfo[playerid][pSpectateID]
and

Код:
PInfo[playerid][pSpectateID] = -1;
You set it to -1, you wont find anybody to spectate next. Your code (given below)

Код:
if(!fl)
	{
	    PInfo[playerid][pSpectateID] = -1;
	    SpectateNext(playerid);
	}
calls SpectateNext again.... you set it to -1 and then call SpectateNext again, this calls SpectateNext again, this again calls SpectateNext again.... this is an infinite loop.
How i fixed this ? I did not know you so
Reply


Messages In This Thread
[debug] Run time error 3: "Stack/heap collision (insufficient stack size) - by Ilai14 - 17.05.2016, 13:25
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size) - by Yashas - 17.05.2016, 14:11
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size) - by Ilai14 - 17.05.2016, 14:44
Re: [debug] Run time error 3: "Stack/heap collision (insufficient stack size) - by Yashas - 17.05.2016, 15:08

Forum Jump:


Users browsing this thread: 3 Guest(s)