Raised This Month: $12 Target: $400
 3% 

"while"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KamiN
Senior Member
Join Date: Jun 2011
Old 11-25-2011 , 08:09   "while"
Reply With Quote #1

Can any of these whiles couse server's crash without any error? I heard somwere that with "while" u might creat a permanent cicle witch crashes ur server but doesnt show any error. So sometimes i get this crash, but dont know becouse witch plugin.

1
Code:
while((pos <= sizeof(g_Buttons)) && (ent[0] = engfunc(EngFunc_FindEntityByString, ent[0], "classname", "info_player_deathmatch")))
{
pev(ent[0], pev_origin, origin)
while((ent[1] = engfunc(EngFunc_FindEntityInSphere, ent[1], origin, CELL_RADIUS)))
{
    if(!is_valid_ent(ent[1]))
        continue
        
    entity_get_string(ent[1], EV_SZ_classname, info, charsmax(info))
    if(!equal(info, "func_door"))
            continue
            
    entity_get_string(ent[1], EV_SZ_targetname, info, charsmax(info))
    if(!info[0])
            continue
            
    if(TrieKeyExists(g_CellManagers, info))
            {
                TrieGetCell(g_CellManagers, info, ent[2])
            }
        else
            {
                ent[2] = engfunc(EngFunc_FindEntityByString, 0, "target", info)
            }
            
    if(is_valid_ent(ent[2]) && (in_array(ent[2], g_Buttons, sizeof(g_Buttons)) < 0))
            {
                g_Buttons[pos] = ent[2]
                pos++
                break
            }
        }
    }
TrieDestroy(g_CellManagers)
}
2
Code:
      while ( gNum < MAX_MAPS && read_file("mapcycle.txt",line++,gMap,63,i) )
    {
        if ( gMap[0] == ';' ) continue

        if (equali(gMap,map))
        {
            cyclerfile = true
            break
        }
        ++gNum
    } return PLUGIN_CONTINUE
3
Code:
    while (nServerCount < g_nServerCount)
    {
        format(sFullAddress, MAX_SERVERADDRESS_LEN - 1, "%s:%d", g_saServerAddresses[nServerCount], g_naServerPorts[nServerCount])
        if (equal(sFullAddress, sTmpOwnAddress) || equal(sFullAddress, sTmpServerIP))
        {
            g_nOwnServer = nServerCount
            break
        }
        nServerCount++
    }
---

4
Code:
while (div > result)            // end when div == result, or just below 
    {
        div = (div + result) / 2;    // take mean value as new divisor 
        result = num / div;
    }
5
Code:
while ((iWPNidx = find_ent_by_class(iWPNidx, wpn)) != 0)
            {
                if (id == entity_get_edict(iWPNidx, EV_ENT_owner)) 
                {
                    cs_set_weapon_ammo(iWPNidx, getMaxClipAmmo(wpnid));
                    break;
                }
            }
6
Code:
    while( (line = read_file(zonefile , line , input , 127 , len) ) != 0 ) 
    {
        if (!strlen(input)  || (input[0] == ';')) continue;    // Kommentar oder Leerzeile

        new data[20], zm = 0, ct        // "abgebrochenen" Daten - ZoneMode - CamperTime
        new Float:mins[3], Float:maxs[3], Float:pos[3]    // Gro?e & Position

        // Zone abrufen
        strbreak(input, data, 20, input, 999)
        zm = -1
        for(new i = 0; ZONEMODE:i < ZONEMODE; ZONEMODE:i++)
        {
            // Anderungen von CS:CZ zu allen Mods
            if (equal(data, "wgz_camper_te")) format(data, 19, "wgz_camper_t1")
            if (equal(data, "wgz_camper_ct")) format(data, 19, "wgz_camper_t2")
            if (equal(data, zonename[ZONEMODE:i])) zm = i;
        }
        
        if (zm == -1)
        {
            log_amx("undefined zone -> '%s' ... dropped", data)
            continue;
        }
        
        // Position holen
        strbreak(input, data, 20, input, 999);    pos[0] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    pos[1] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    pos[2] = str_to_float(data);
        
        // Dimensionen
        strbreak(input, data, 20, input, 999);    mins[0] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    mins[1] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    mins[2] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    maxs[0] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    maxs[1] = str_to_float(data);
        strbreak(input, data, 20, input, 999);    maxs[2] = str_to_float(data);

        if ((ZONEMODE:zm == ZM_CAMPING) || (ZONEMODE:zm == ZM_CAMPING_T1) || (ZONEMODE:zm == ZM_CAMPING_T2))
        {
            // Campertime wird immer mitgeliefert
            strbreak(input, data, 20, input, 999)
            ct = str_to_num(data)
        }

        // und nun noch erstellen
        CreateZone(pos, mins, maxs, zm, ct);
    }
7
Code:
while(engfunc(EngFunc_PointContents, vOrigin) == CONTENTS_EMPTY)
        vOrigin[2] += 5.0;

Last edited by KamiN; 11-25-2011 at 08:15.
KamiN is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-25-2011 , 14:06   Re: "while"
Reply With Quote #2

Any while loop that is not handled correctly can create and infinite loop. The easiest way to find out which is causing it is to put some print or log functions in each and see which one shows up infinitely. I would recommend server_print().
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 08:52.


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