viewing paste Unknown #5973 | C

Posted on the | Last edited on
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
int script_repairall_sub(TBL_PC *sd){
    int i, repaircounter=0;
    for(i = 0; i < MAX_INVENTORY; i++){
        if(sd->status.inventory[i].nameid && sd->status.inventory[i].attribute)
        {
            sd->status.inventory[i].attribute = 0;
            clif_produceeffect(sd,0,sd->status.inventory[i].nameid);
            repaircounter++;
        }
    }
    return repaircounter;
}
/*==========================================
 * repairall
 *------------------------------------------*/
BUILDIN_FUNC(repairall)
    {
    int i, repaircounter = 0, type=0, val;
    const char *str;
    script_data data;
    TBL_PC *sd, *pl_sd;
    struct s_mapiterator *iter;
 
    if(script_hasdata(st,2)){
        if(script_hasdata(st,3) == 0){
            ShowError("buildin_repairall: missing arg val for type=%d");
            script_pushint(st,-1);
            return 0;
        }
        type = script_getnum(st,2);
 
        switch(type){ //check if val valid for type
            case 1: //map
                str = script_getstr(st,3);
                if( (val = map_mapname2mapid(str)) < 0 ){ //map not found
                    script_pushint(st,-1);
                    return 0;
                }
                if(script_hasdata(st,4)){ //instance support
                    val = instance_map2imap(m, script_getnum(st,4));
                }
                break;
            case 2:  //guild
                if(guild_search(val) == NULL){ //guild not found
                    script_pushint(st,-1);
                    return 0;
                }
                val = script_getnum(st, 3);
                break;
            case 3: //team
                val = script_getnum(st, 3);
                if(party_search(val) == NULL){ //team not found
                    script_pushint(st,-1);
                    return 0;
                }
                break;
            case 4: //bg
                val = script_getnum(st, 3);
                if(bg_team_search(val) == NULL){ //bg not found
                     script_pushint(st,-1);
                    return 0;
                }
                break;
        }
 
        iter = mapit_getallusers();
        for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter)) {
            switch(type){
            case 1: if(val != pl_sd->bl.m) continue; break; //mapcheck
            case 2: if(pl_sd->guild == 0 || val != pl_sd->status.guild_id) continue; break; //guildchk
            case 3: if(pl_sd->status.party_id == 0 || val != pl_sd->status.party_id) continue; break; //teamchk
            case 4: if(pl_sd->bg_id == 0 || val != pl_sd->bg_id) continue; break; //bgchk
            }
            repaircounter += script_repairall_sub(pl_sd);
        }
        mapit_free(iter);
    }
    else { //fallback no arg backwarg comp
        sd = script_rid2sd(st);
        if(sd == NULL)
            return 0;
        repaircounter = script_repairall_sub(sd);
    }
 
    if(repaircounter)
    {
        clif_misceffect(&sd->bl, 3);
        clif_equiplist(sd);
    }
    script_pushint(st,repaircounter);
 
    return 0;
}
Viewed 1630 times, submitted by lighta.