You ignore my bug report for a long time.
A item lost when casting a multiset to array!!!!
mapping special_attrs=([]);
void main() { multiset from=(<>); array _to=({(<"Stone","1","%70">),(<"Stone","2","%70">)}); multiset to; array rate=({}); int sum;
foreach(_to,multiset m){ int found; foreach(m;string k;int one){ if(k[0]=='%'){ int n; sscanf(k,"%%%d",n); rate+=({n}); sum+=n; m[k]=0; found=1; break; } } if(!found){ rate+=({1}); sum+=1; } } //int r=random(sum); int r=80; for(int i=0;i<sizeof(rate);i++){ if(r<rate[i]){ to=_to[i]; break; }else{ r-=rate[i]; } }
multiset unchanged=from&to; multiset special_add=(to-unchanged)&(multiset)(indices(special_attrs)); multiset special_del=(from-unchanged)&(multiset)(indices(special_attrs)); multiset direct_del=filter(from-unchanged,lambda(string x){if(x[0]!='!') return 1;else return 0;}); multiset direct_add=to-unchanged-special_add; werror("direct_add=%O\n",(direct_add)); werror("BUT (array)direct_add=%O\n",(array)(direct_add));
}
Output:
direct_add=(< /* 1 element */ "Stone", "2"
)
BUT (array)direct_add=({ /* 1 element */ "2" })