| 5400 | } |
| 5401 | |
| 5402 | int |
| 5403 | rnd_class(int first, int last) |
| 5404 | { |
| 5405 | int i, x, sum = 0; |
| 5406 | |
| 5407 | if (last > first) { |
| 5408 | for (i = first; i <= last; i++) |
| 5409 | sum += objects[i].oc_prob; |
| 5410 | if (!sum) /* all zero, so equal probability */ |
| 5411 | return rn1(last - first + 1, first); |
| 5412 | |
| 5413 | x = rnd(sum); |
| 5414 | for (i = first; i <= last; i++) |
| 5415 | if ((x -= objects[i].oc_prob) <= 0) |
| 5416 | return i; |
| 5417 | } |
| 5418 | return (first == last) ? first : STRANGE_OBJECT; |
| 5419 | } |
| 5420 | |
| 5421 | const char * |
| 5422 | Japanese_item_name(int i, const char *ordinaryname) |
no test coverage detected