| 377 | * end of the dungeon. |
| 378 | */ |
| 379 | staticfn int |
| 380 | level_range( |
| 381 | xint16 dgn, |
| 382 | int base, int randc, int chain, |
| 383 | struct proto_dungeon *pd, |
| 384 | int *adjusted_base) |
| 385 | { |
| 386 | int lmax = svd.dungeons[dgn].num_dunlevs; |
| 387 | |
| 388 | if (chain >= 0) { /* relative to a special level */ |
| 389 | s_level *levtmp = pd->final_lev[chain]; |
| 390 | if (!levtmp) |
| 391 | panic("level_range: empty chain level!"); |
| 392 | |
| 393 | base += levtmp->dlevel.dlevel; |
| 394 | } else { /* absolute in the dungeon */ |
| 395 | /* from end of dungeon */ |
| 396 | if (base < 0) |
| 397 | base = (lmax + base + 1); |
| 398 | } |
| 399 | |
| 400 | if (base < 1 || base > lmax) |
| 401 | panic("level_range: base value out of range"); |
| 402 | |
| 403 | *adjusted_base = base; |
| 404 | |
| 405 | if (randc == -1) { /* from base to end of dungeon */ |
| 406 | return (lmax - base + 1); |
| 407 | } else if (randc) { |
| 408 | /* make sure we don't run off the end of the dungeon */ |
| 409 | return (((base + randc - 1) > lmax) ? lmax - base + 1 : randc); |
| 410 | } /* else only one choice */ |
| 411 | return 1; |
| 412 | } |
| 413 | |
| 414 | staticfn xint16 |
| 415 | parent_dlevel(const char *s, struct proto_dungeon *pd) |
no test coverage detected