| 568 | #define MAXCHOICES 32 |
| 569 | |
| 570 | gentity_t *G_PickTarget (char *targetname) |
| 571 | { |
| 572 | gentity_t *ent = NULL; |
| 573 | int num_choices = 0; |
| 574 | gentity_t *choice[MAXCHOICES]; |
| 575 | |
| 576 | if (!targetname) |
| 577 | { |
| 578 | gi.Printf("G_PickTarget called with NULL targetname\n"); |
| 579 | return NULL; |
| 580 | } |
| 581 | |
| 582 | while(1) |
| 583 | { |
| 584 | ent = G_Find (ent, FOFS(targetname), targetname); |
| 585 | if (!ent) |
| 586 | break; |
| 587 | choice[num_choices++] = ent; |
| 588 | if (num_choices == MAXCHOICES) |
| 589 | break; |
| 590 | } |
| 591 | |
| 592 | if (!num_choices) |
| 593 | { |
| 594 | gi.Printf("G_PickTarget: target %s not found\n", targetname); |
| 595 | return NULL; |
| 596 | } |
| 597 | |
| 598 | return choice[rand() % num_choices]; |
| 599 | } |
| 600 | |
| 601 | void G_UseTargets2 (gentity_t *ent, gentity_t *activator, const char *string) |
| 602 | { |
no test coverage detected