| 405 | } |
| 406 | |
| 407 | staticfn int |
| 408 | shkveg(void) |
| 409 | { |
| 410 | int i, j, maxprob, prob; |
| 411 | char oclass = FOOD_CLASS; |
| 412 | int ok[NUM_OBJECTS]; |
| 413 | |
| 414 | (void) memset((genericptr_t) ok, 0, sizeof ok); /* lint suppression */ |
| 415 | j = maxprob = 0; |
| 416 | for (i = svb.bases[(int) oclass]; i < NUM_OBJECTS; ++i) { |
| 417 | if (objects[i].oc_class != oclass) |
| 418 | break; |
| 419 | |
| 420 | if (veggy_item((struct obj *) 0, i)) { |
| 421 | ok[j++] = i; |
| 422 | maxprob += objects[i].oc_prob; |
| 423 | } |
| 424 | } |
| 425 | if (maxprob < 1) |
| 426 | panic("shkveg no veggy objects"); |
| 427 | prob = rnd(maxprob); |
| 428 | |
| 429 | j = 0; |
| 430 | i = ok[0]; |
| 431 | while ((prob -= objects[i].oc_prob) > 0) { |
| 432 | j++; |
| 433 | i = ok[j]; |
| 434 | } |
| 435 | |
| 436 | if (objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) |
| 437 | panic("shkveg probtype error, oclass=%d i=%d", (int) oclass, i); |
| 438 | return i; |
| 439 | } |
| 440 | |
| 441 | /* make a random item for health food store */ |
| 442 | staticfn void |
no test coverage detected