MCPcopy Create free account
hub / github.com/NetHack/NetHack / makemaz

Function makemaz

src/mkmaze.c:1126–1223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1124}
1125
1126void
1127makemaz(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

Callers 1

makelevelFunction · 0.85

Calls 15

Is_specialFunction · 0.85
rndFunction · 0.85
dunlevs_in_dungeonFunction · 0.85
dunlevFunction · 0.85
strrchrFunction · 0.85
check_ransackedFunction · 0.85
load_specialFunction · 0.85
dmonsfreeFunction · 0.85
rn2Function · 0.85
Invocation_levFunction · 0.85
create_mazeFunction · 0.85
wallificationFunction · 0.85

Tested by

no test coverage detected