is rolenum compatible with any racenum/gendnum/alignnum constraints? */
| 968 | |
| 969 | /* is rolenum compatible with any racenum/gendnum/alignnum constraints? */ |
| 970 | boolean |
| 971 | ok_role(int rolenum, int racenum, int gendnum, int alignnum) |
| 972 | { |
| 973 | int i; |
| 974 | short allow; |
| 975 | |
| 976 | if (IndexOkT(rolenum, roles)) { |
| 977 | if (gr.rfilter.roles[rolenum]) |
| 978 | return FALSE; |
| 979 | allow = roles[rolenum].allow; |
| 980 | if (IndexOkT(racenum, races) |
| 981 | && !(allow & races[racenum].allow & ROLE_RACEMASK)) |
| 982 | return FALSE; |
| 983 | if (gendnum >= 0 && gendnum < ROLE_GENDERS |
| 984 | && !(allow & genders[gendnum].allow & ROLE_GENDMASK)) |
| 985 | return FALSE; |
| 986 | if (alignnum >= 0 && alignnum < ROLE_ALIGNS |
| 987 | && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK)) |
| 988 | return FALSE; |
| 989 | return TRUE; |
| 990 | } else { |
| 991 | /* random; check whether any selection is possible */ |
| 992 | for (i = 0; i < SIZE(roles) - 1; i++) { |
| 993 | if (gr.rfilter.roles[i]) |
| 994 | continue; |
| 995 | allow = roles[i].allow; |
| 996 | if (IndexOkT(racenum, races) |
| 997 | && !(allow & races[racenum].allow & ROLE_RACEMASK)) |
| 998 | continue; |
| 999 | if (gendnum >= 0 && gendnum < ROLE_GENDERS |
| 1000 | && !(allow & genders[gendnum].allow & ROLE_GENDMASK)) |
| 1001 | continue; |
| 1002 | if (alignnum >= 0 && alignnum < ROLE_ALIGNS |
| 1003 | && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK)) |
| 1004 | continue; |
| 1005 | return TRUE; |
| 1006 | } |
| 1007 | return FALSE; |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | /* pick a random role subject to any racenum/gendnum/alignnum constraints */ |
| 1012 | /* If pickhow == PICK_RIGID a role is returned only if there is */ |
no outgoing calls
no test coverage detected