| 1298 | } |
| 1299 | |
| 1300 | staticfn void |
| 1301 | ini_inv(const struct trobj *trop) |
| 1302 | { |
| 1303 | struct obj *obj; |
| 1304 | int otyp; |
| 1305 | boolean got_sp1 = FALSE; /* got a level 1 spellbook? */ |
| 1306 | long quan; |
| 1307 | |
| 1308 | if (u.uroleplay.pauper) /* pauper gets no items */ |
| 1309 | return; |
| 1310 | |
| 1311 | quan = trquan(trop); |
| 1312 | while (trop->trclass) { |
| 1313 | otyp = (int) trop->trotyp; |
| 1314 | if (otyp != UNDEF_TYP) { |
| 1315 | obj = mksobj(otyp, TRUE, FALSE); |
| 1316 | } else { /* UNDEF_TYP */ |
| 1317 | obj = ini_inv_mkobj_filter(trop->trclass, got_sp1); |
| 1318 | otyp = obj->otyp; |
| 1319 | /* Heavily relies on the facts that 1) we create wands |
| 1320 | * before rings, that 2) we create rings before |
| 1321 | * spellbooks, and that 3) not more than 1 object of a |
| 1322 | * particular symbol is to be prohibited. (For more |
| 1323 | * objects, we need more nocreate variables...) |
| 1324 | */ |
| 1325 | switch (otyp) { |
| 1326 | case WAN_POLYMORPH: |
| 1327 | case RIN_POLYMORPH: |
| 1328 | case POT_POLYMORPH: |
| 1329 | gn.nocreate = RIN_POLYMORPH_CONTROL; |
| 1330 | break; |
| 1331 | case RIN_POLYMORPH_CONTROL: |
| 1332 | gn.nocreate = RIN_POLYMORPH; |
| 1333 | gn.nocreate2 = SPE_POLYMORPH; |
| 1334 | gn.nocreate3 = POT_POLYMORPH; |
| 1335 | } |
| 1336 | /* Don't have 2 of the same ring or spellbook */ |
| 1337 | if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS) |
| 1338 | gn.nocreate4 = otyp; |
| 1339 | } |
| 1340 | /* Put post-creation object adjustments that don't depend on whether |
| 1341 | * it was UNDEF_TYP or not after this. */ |
| 1342 | |
| 1343 | otyp = ini_inv_obj_substitution(trop, obj); |
| 1344 | nhUse(otyp); |
| 1345 | |
| 1346 | /* nudist gets no armor */ |
| 1347 | if (u.uroleplay.nudist && obj->oclass == ARMOR_CLASS) { |
| 1348 | dealloc_obj(obj); |
| 1349 | trop++; |
| 1350 | continue; |
| 1351 | } |
| 1352 | |
| 1353 | if (ini_inv_adjust_obj(trop, obj)) |
| 1354 | quan = 1; |
| 1355 | obj = addinv(obj); |
| 1356 | |
| 1357 | /* First spellbook should be level 1 - did we get it? */ |
no test coverage detected