Raised This Month: $ Target: $400
 0% 

How to avoid recursion here?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
igor.ol13
Junior Member
Join Date: Nov 2012
Old 01-14-2013 , 17:35   How to avoid recursion here?
Reply With Quote #1

I have no one function that is calling himself, I verified. I've found the problem, but it doesn't make sense for me (I'll show)... Someone has an idea? Any comments are welcome

ps: I don't know if this code is working right

So, I have this func, note fill_player call, if I comment that line disappears recursion
PHP Code:
bool:info_login(id)
{
    static
        
login_info[MAX_LOGIN_STR 1 char],
        
pass_info[MAX_PASS_STR 1 char],
        
login_uid,
        
uid_str[11 char],
        
tempA[34 char],
        
tempB[1 char];
        
    
get_user_info(id"_rLogin"login_infoMAX_LOGIN_STR);
    
login_uid nvault_get(vault[login], login_info)
    if (
login_uid 0)
    {
        
get_user_info(id"_rPass"pass_infoMAX_PASS_STR);
        
num_to_str(login_uiduid_str10);
        
nvault_get(vault[data], uid_strtempAMAX_PASS_STR);
        
split(tempAtempAMAX_PASS_STRtempB0";");
        
        if (
equal(tempApass_info)) //senha correta
        
{
            
// logged in
            
cl_uid[set_id(id)] = login_uid;
            
fill_player(iduid_str);
            
set_user_hud_info(id, {0,255,0}, "O login automatico esta ativado, voce ja esta logado ;)");
            
set_user_hud_info(id, {200,255,200}, "Digite a qualquer momento /registro para alterar informacoes de sua conta.");
            return 
true;
        }
        else if (
login_info[0] != && pass_info[0] != 0)
        {
            
set_user_hud_info(id, {255,0,0}, "O login automatico esta ativado, mas a sua senha ou seu login esta incorreto!");
            return 
false;
        }
    }
    return 
false;

Now here is my fill_player func, note that info_login is never called here! But if I switch internal by public (and remove default values too), recursion disappears too :s
PHP Code:
fill_player(id, const uid[], operacao:op obterdb:dado pass, const novo_dado[] = -1)
{
    static
        
str_temp[sizeof(pl_dados)+11],
        
strA[60 char],
        
len;
    if (
op == obter)
    {
        
nvault_get(vault[data], uidstr_tempcharsmax(str_temp));
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
copy(pl_dados[pass], charsmax(pl_dados[pass]), strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
copy(pl_dados[nickname], charsmax(pl_dados[nickname]), strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
copy(pl_dados[loginname], charsmax(pl_dados[loginname]), strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
copy(pl_dados[steam], charsmax(pl_dados[steam]), strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
pl_dados[aps] = str_to_num(strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
copy(pl_dados[email], charsmax(pl_dados[email]), strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
pl_dados[regdate1] = str_to_num(strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
pl_dados[regdate2] = str_to_num(strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
pl_dados[regdate3] = str_to_num(strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
pl_dados[birthdate1] = str_to_num(strA);
        
split(str_tempstrAcharsmax(strA), str_tempcharsmax(str_temp), ";");
        
pl_dados[birthdate2] = str_to_num(strA);
        
ArrayPushArray(cl_dadospl_dados);
        
cl_id[set_id(id)] = ar_id;
        
ar_id++;        
    }
    else if (
op == salvar)
    {
        
len 0;
        
ArrayGetArray(cl_dadoscl_id[set_id(id)], pl_dados);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"pl_dados[pass]);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"pl_dados[nickname]);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"pl_dados[loginname]);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"pl_dados[steam]);
        
num_to_str(pl_dados[aps], strAcharsmax(strA));
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"strA);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"pl_dados[email]);
        
formatex(strAcharsmax(strA), "%d;%d;%d"pl_dados[regdate1], pl_dados[regdate2], pl_dados[regdate3]);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s;"strA);
        
formatex(strAcharsmax(strA), "%d;%d"pl_dados[birthdate1], pl_dados[birthdate2]);
        
len += formatex(str_temp[len], (charsmax(str_temp) - len), "%s"strA);
        
nvault_pset(vault[data], uidstr_temp);
    }
    else if (
op == atualizar)
    {
        
ArrayGetArray(cl_dadoscl_id[set_id(id)], pl_dados);
        
ArrayDeleteItem(cl_dadoscl_id[set_id(id)]);
        
copy(pl_dados[dado], sizeof(dado), novo_dado);
        
ArrayInsertArrayBefore(cl_dadoscl_id[set_id(id)], pl_dados);
    }
    else
        return;
    return;

why is this happening? what can I do?

Last edited by igor.ol13; 01-14-2013 at 17:36.
igor.ol13 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-15-2013 , 00:39   Re: How to avoid recursion here?
Reply With Quote #2

Put debugs in your code, each line something to print or to write in a file.
Then see where is the problem ;)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode