viewing paste Unknown #6936 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
BUILDIN(setarray)
{
    struct script_data* data;
    const char* name;
    int32 start;
    int32 end;
    int32 id;
    int32 i;
    TBL_PC* sd = NULL;
    
    data = script_getdata(st, 2);
    if( !data_isreference(data) )
    {
        ShowError("script:setarray: not a variable\n");
        script_reportdata(data);
        st->state = END;
        return false;// not a variable
    }
    
    id = reference_getid(data);
    start = reference_getindex(data);
    name = reference_getname(data);
    if( not_array_variable(*name) )
    {
        ShowError("script:setarray: illegal scope\n");
        script_reportdata(data);
        st->state = END;
        return false;// not supported
    }
    
    if( not_server_variable(*name) )
    {
        sd = script_rid2sd(st);
        if( sd == NULL )
            return true;// no player attached
    }
    
    end = start + script_lastdata(st) - 2;
    if( end > SCRIPT_MAX_ARRAYSIZE )
        end = SCRIPT_MAX_ARRAYSIZE;
    
    if( is_string_variable(name) )
    {// string array
        for( i = 3; start < end; ++start, ++i )
            set_reg(st, sd, reference_uid(id, start), name, (void*)script_getstr(st,i), reference_getref(data));
    }
    else
    {// int array
        for( i = 3; start < end; ++start, ++i )
            set_reg(st, sd, reference_uid(id, start), name, (void*)__64BPTRSIZE(script_getnum(st,i)), reference_getref(data));
    }
    return true;
}
 
Viewed 722 times, submitted by Guest.