… | |
… | |
251 | if (op->stats.food < 0) |
251 | if (op->stats.food < 0) |
252 | destroy = 1; |
252 | destroy = 1; |
253 | } |
253 | } |
254 | else |
254 | else |
255 | { |
255 | { |
256 | int mat = op->material; |
256 | int mat = op->materials; |
257 | |
257 | |
258 | if (mat & M_PAPER |
258 | if (mat & M_PAPER |
259 | || mat & M_LEATHER |
259 | || mat & M_LEATHER |
260 | || mat & M_WOOD |
260 | || mat & M_WOOD |
261 | || mat & M_ORGANIC |
261 | || mat & M_ORGANIC |
… | |
… | |
276 | } |
276 | } |
277 | |
277 | |
278 | /* convert materialname to materialtype_t */ |
278 | /* convert materialname to materialtype_t */ |
279 | |
279 | |
280 | materialtype_t * |
280 | materialtype_t * |
281 | name_to_material (const char *name) |
281 | name_to_material (const shstr &name) |
282 | { |
282 | { |
283 | materialtype_t *mt, *nmt; |
283 | for (materialtype_t *mt = materialt; mt && mt->next; mt = mt->next) |
284 | |
284 | if (name == mt->name) |
285 | mt = NULL; |
|
|
286 | for (nmt = materialt; nmt != NULL && nmt->next != NULL; nmt = nmt->next) |
|
|
287 | { |
|
|
288 | if (strcmp (name, nmt->name) == 0) |
|
|
289 | { |
|
|
290 | mt = nmt; |
|
|
291 | break; |
|
|
292 | } |
|
|
293 | } |
|
|
294 | return mt; |
285 | return mt; |
|
|
286 | |
|
|
287 | return materialt; |
295 | } |
288 | } |
296 | |
289 | |
297 | /* when doing transmutation of objects, we have to recheck the resistances, |
290 | /* when doing transmutation of objects, we have to recheck the resistances, |
298 | * as some that did not apply previously, may apply now. |
291 | * as some that did not apply previously, may apply now. |
299 | */ |
292 | */ |
… | |
… | |
348 | |
341 | |
349 | if (nmt == NULL) |
342 | if (nmt == NULL) |
350 | { |
343 | { |
351 | lmt = NULL; |
344 | lmt = NULL; |
352 | #ifndef NEW_MATERIAL_CODE |
345 | #ifndef NEW_MATERIAL_CODE |
353 | for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) |
346 | for (mt = materialt; mt && mt->next; mt = mt->next) |
354 | { |
347 | { |
355 | if (op->material & mt->material) |
348 | if (op->materials & mt->material) |
356 | { |
349 | { |
357 | lmt = mt; |
350 | lmt = mt; |
358 | break; |
351 | break; |
359 | } |
352 | } |
360 | } |
353 | } |
361 | |
354 | |
362 | #else |
355 | #else |
363 | for (mt = materialt; mt != NULL && mt->next != NULL; mt = mt->next) |
356 | for (mt = materialt; mt && mt->next; mt = mt->next) |
364 | { |
357 | { |
365 | if (op->material & mt->material && rndm (1, 100) <= mt->chance && |
358 | if (op->materials & mt->material && rndm (1, 100) <= mt->chance && |
366 | difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0)) |
359 | difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0)) |
367 | { |
360 | { |
368 | lmt = mt; |
361 | lmt = mt; |
369 | if (!(op->is_weapon () || op->is_armor ())) |
362 | if (!(op->is_weapon () || op->is_armor ())) |
370 | break; |
363 | break; |