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;
}