viewing paste Unknown #6381 | 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
/*==========================================
 * Returns the name of a duplicated map
 *
 * instance_mapname <map_name>{,<instance_id};
 *------------------------------------------*/
BUILDIN_FUNC(instance_mapname)
{
    const char *str;
    char iname[12];
    int16 m;
    short instance_id = 0;
 
    str = script_getstr(st,2);
    if( script_hasdata(st,3) )
        instance_id = script_getnum(st,3);
    else
        instance_id = buildin_instancegetid_sub(st);
 
    snprintf(iname, sizeof(iname), "%03d%s", instance_id, str);
 
    if( !instance_id || (m = map_mapname2mapid(iname)) < 0 )
        script_pushconststr(st, "");
    else
        script_pushconststr(st, map[m].name);
 
    return 0;
}
Viewed 623 times, submitted by Guest.