| 1124 | } |
| 1125 | |
| 1126 | void |
| 1127 | makemaz(const char *s) |
| 1128 | { |
| 1129 | char protofile[20]; |
| 1130 | s_level *sp = Is_special(&u.uz); |
| 1131 | coord mm; |
| 1132 | |
| 1133 | if (*s) { |
| 1134 | if (sp && sp->rndlevs) |
| 1135 | Snprintf(protofile, sizeof protofile, |
| 1136 | "%s-%d", s, rnd((int) sp->rndlevs)); |
| 1137 | else |
| 1138 | Strcpy(protofile, s); |
| 1139 | } else if (*(svd.dungeons[u.uz.dnum].proto)) { |
| 1140 | if (dunlevs_in_dungeon(&u.uz) > 1) { |
| 1141 | if (sp && sp->rndlevs) |
| 1142 | Snprintf(protofile, sizeof protofile, |
| 1143 | "%s%d-%d", svd.dungeons[u.uz.dnum].proto, |
| 1144 | dunlev(&u.uz), rnd((int) sp->rndlevs)); |
| 1145 | else |
| 1146 | Snprintf(protofile, sizeof protofile, |
| 1147 | "%s%d", svd.dungeons[u.uz.dnum].proto, |
| 1148 | dunlev(&u.uz)); |
| 1149 | } else if (sp && sp->rndlevs) { |
| 1150 | Snprintf(protofile, sizeof protofile, |
| 1151 | "%s-%d", svd.dungeons[u.uz.dnum].proto, |
| 1152 | rnd((int) sp->rndlevs)); |
| 1153 | } else |
| 1154 | Strcpy(protofile, svd.dungeons[u.uz.dnum].proto); |
| 1155 | |
| 1156 | } else |
| 1157 | Strcpy(protofile, ""); |
| 1158 | |
| 1159 | /* SPLEVTYPE format is "level-choice,level-choice"... */ |
| 1160 | if (wizard && *protofile && sp && sp->rndlevs) { |
| 1161 | char *ep = getenv("SPLEVTYPE"); /* not nh_getenv */ |
| 1162 | |
| 1163 | if (ep) { |
| 1164 | /* strrchr always succeeds due to code in prior block */ |
| 1165 | int len = (int) ((strrchr(protofile, '-') - protofile) + 1); |
| 1166 | |
| 1167 | while (ep && *ep) { |
| 1168 | if (!strncmp(ep, protofile, len)) { |
| 1169 | int pick = atoi(ep + len); |
| 1170 | |
| 1171 | /* use choice only if valid */ |
| 1172 | if (pick > 0 && pick <= (int) sp->rndlevs) |
| 1173 | Sprintf(protofile + len, "%d", pick); |
| 1174 | break; |
| 1175 | } else { |
| 1176 | ep = strchr(ep, ','); |
| 1177 | if (ep) |
| 1178 | ++ep; |
| 1179 | } |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 |
no test coverage detected