PDA

View Full Version : Recursion. WHERE! (Result: Stack/Heap)


Crayder
28/03/2015, 05:58 PM
Here is what I added, and when I remove it the recursion goes away so it's definitely the problem:public OnRconCommand(cmd[])
{
if(!strcmp(cmd, "copymap", false, 7))
{
new map[2][128], Float:offset[6];
if(sscanf(cmd[7], "s[128]s[128]ffffff", map[0], map[1], offset[0], offset[1], offset[2], offset[3], offset[4], offset[5]))
return print("SYNTAX: copymap [source file] [output file] [offsets]");

else
{
new count = GetTickCount(),
Objects[2000][ObjInfo],
string[256],
index,
var_from_line[32],
loaded,
File:files[2],
line[128];

files[0] = fopen(map[0], io_read);
if(!files[0])
return printf("Error opening: %s",map[0]);
files[1] = fopen(map[1], io_write);
if(!files[1])
return printf("Error opening: %s",map[1]);

while(fread(files[0], string) > 0) if((strfind(string, "CreateDynamicObject", false) != -1) && strdel(string, 0, 20))
{
index = 0;
index = token_by_delim(string,var_from_line,',',index); Objects[loaded][o_model] = strval(var_from_line);
index = token_by_delim(string,var_from_line,',',index+1); Objects[loaded][o_x] = floatstr(var_from_line);
index = token_by_delim(string,var_from_line,',',index+1); Objects[loaded][o_y] = floatstr(var_from_line);
index = token_by_delim(string,var_from_line,',',index+1); Objects[loaded][o_z] = floatstr(var_from_line);
index = token_by_delim(string,var_from_line,',',index+1); Objects[loaded][o_rx] = floatstr(var_from_line);
index = token_by_delim(string,var_from_line,',',index+1); Objects[loaded][o_ry] = floatstr(var_from_line);
index = token_by_delim(string,var_from_line,',',index+1); Objects[loaded][o_rz] = floatstr(var_from_line);

format(line, sizeof(line), "CreateDynamicObject(%i, %f, %f, %f, %f, %f, %f);\r\n", Objects[loaded][o_model], Objects[loaded][o_x]+offset[0], Objects[loaded][o_y]+offset[1], Objects[loaded][o_z]+offset[2], Objects[loaded][o_rx]+offset[3], Objects[loaded][o_ry]+offset[4], Objects[loaded][o_rz]+offset[5]);
fwrite(files[1], line);

loaded++;
}
fclose(files[0]);
fclose(files[1]);

return printf("Copied %i objects in %d mc.",loaded,(GetTickCount()-count));
}
}
return 1;
}Honestly this is brainfucking me. The loop is not infinite and there aren't any recursive function calls. I'm probably overlooking something obvious. Please help!


EDIT: Fixed, fuck me. The problem was the objects array, I don't know why I was storing all the objects. The array wouldn't suffice even if I was, my map is 26410 objects.