is racenum compatible with any rolenum/gendnum/alignnum constraints? */
| 1034 | |
| 1035 | /* is racenum compatible with any rolenum/gendnum/alignnum constraints? */ |
| 1036 | boolean |
| 1037 | ok_race(int rolenum, int racenum, int gendnum, int alignnum) |
| 1038 | { |
| 1039 | int i; |
| 1040 | short allow; |
| 1041 | |
| 1042 | if (IndexOkT(racenum, races)) { |
| 1043 | if (gr.rfilter.mask & races[racenum].selfmask) |
| 1044 | return FALSE; |
| 1045 | allow = races[racenum].allow; |
| 1046 | if (IndexOkT(rolenum, roles) |
| 1047 | && !(allow & roles[rolenum].allow & ROLE_RACEMASK)) |
| 1048 | return FALSE; |
| 1049 | if (gendnum >= 0 && gendnum < ROLE_GENDERS |
| 1050 | && !(allow & genders[gendnum].allow & ROLE_GENDMASK)) |
| 1051 | return FALSE; |
| 1052 | if (alignnum >= 0 && alignnum < ROLE_ALIGNS |
| 1053 | && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK)) |
| 1054 | return FALSE; |
| 1055 | return TRUE; |
| 1056 | } else { |
| 1057 | /* random; check whether any selection is possible */ |
| 1058 | for (i = 0; i < SIZE(races) - 1; i++) { |
| 1059 | if (gr.rfilter.mask & races[i].selfmask) |
| 1060 | continue; |
| 1061 | allow = races[i].allow; |
| 1062 | if (IndexOkT(rolenum, roles) |
| 1063 | && !(allow & roles[rolenum].allow & ROLE_RACEMASK)) |
| 1064 | continue; |
| 1065 | if (gendnum >= 0 && gendnum < ROLE_GENDERS |
| 1066 | && !(allow & genders[gendnum].allow & ROLE_GENDMASK)) |
| 1067 | continue; |
| 1068 | if (alignnum >= 0 && alignnum < ROLE_ALIGNS |
| 1069 | && !(allow & aligns[alignnum].allow & ROLE_ALIGNMASK)) |
| 1070 | continue; |
| 1071 | return TRUE; |
| 1072 | } |
| 1073 | return FALSE; |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | /* Pick a random race subject to any rolenum/gendnum/alignnum constraints. |
| 1078 | If pickhow == PICK_RIGID a race is returned only if there is |
no outgoing calls
no test coverage detected