… | |
… | |
200 | } |
200 | } |
201 | |
201 | |
202 | /* convert materialname to materialtype_t */ |
202 | /* convert materialname to materialtype_t */ |
203 | |
203 | |
204 | materialtype_t * |
204 | materialtype_t * |
205 | name_to_material (const shstr &name) |
205 | name_to_material (const shstr_cmp name) |
206 | { |
206 | { |
207 | for (materialtype_t *mt = materialt; mt && mt->next; mt = mt->next) |
207 | for (materialtype_t *mt = materialt; mt; mt = mt->next) |
208 | if (name == mt->name) |
208 | if (name == mt->name) |
209 | return mt; |
209 | return mt; |
210 | |
210 | |
211 | return 0; |
211 | return 0; |
212 | } |
212 | } |
… | |
… | |
218 | transmute_materialname (object *op, const object *change) |
218 | transmute_materialname (object *op, const object *change) |
219 | { |
219 | { |
220 | materialtype_t *mt; |
220 | materialtype_t *mt; |
221 | int j; |
221 | int j; |
222 | |
222 | |
223 | if (op->materialname == NULL) |
223 | if (!op->materialname) |
224 | return; |
224 | return; |
225 | |
225 | |
226 | if (change->materialname != NULL && strcmp (op->materialname, change->materialname)) |
226 | if (change->materialname && strcmp (op->materialname, change->materialname)) |
227 | return; |
227 | return; |
228 | |
228 | |
229 | if (!op->is_armor ()) |
229 | if (!op->is_armor ()) |
230 | return; |
230 | return; |
231 | |
231 | |
… | |
… | |
251 | void |
251 | void |
252 | set_materialname (object *op, int difficulty, materialtype_t *nmt) |
252 | set_materialname (object *op, int difficulty, materialtype_t *nmt) |
253 | { |
253 | { |
254 | materialtype_t *mt, *lmt; |
254 | materialtype_t *mt, *lmt; |
255 | |
255 | |
256 | if (op->materialname != NULL) |
256 | if (!op->materialname) |
257 | return; |
257 | return; |
258 | |
258 | |
259 | if (nmt == NULL) |
259 | if (nmt) |
|
|
260 | lmt = nmt; |
|
|
261 | else |
260 | { |
262 | { |
261 | lmt = NULL; |
263 | lmt = 0; |
262 | |
264 | |
263 | for (mt = materialt; mt && mt->next; mt = mt->next) |
265 | for (mt = materialt; mt; mt = mt->next) |
264 | if (op->materials & mt->material && rndm (1, 100) <= mt->chance && |
266 | if (op->materials & mt->material && rndm (1, 100) <= mt->chance && |
265 | difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0)) |
267 | difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0)) |
266 | { |
268 | { |
267 | lmt = mt; |
269 | lmt = mt; |
268 | if (!(op->is_weapon () || op->is_armor ())) |
270 | if (!(op->is_weapon () || op->is_armor ())) |
269 | break; |
271 | break; |
270 | } |
272 | } |
271 | } |
273 | } |
272 | else |
|
|
273 | lmt = nmt; |
|
|
274 | |
274 | |
275 | if (lmt != NULL) |
275 | if (lmt) |
276 | { |
276 | { |
277 | if (op->stats.dam && op->is_weapon ()) |
277 | if (op->stats.dam && op->is_weapon ()) |
278 | { |
278 | { |
279 | op->stats.dam += lmt->damage; |
279 | op->stats.dam += lmt->damage; |
280 | if (op->stats.dam < 1) |
280 | if (op->stats.dam < 1) |
… | |
… | |
449 | void |
449 | void |
450 | fork_abort (const char *msg) |
450 | fork_abort (const char *msg) |
451 | { |
451 | { |
452 | if (!fork ()) |
452 | if (!fork ()) |
453 | { |
453 | { |
454 | fprintf (stderr, "background fork_abort in progress, remove me when debugged.\n");//D |
|
|
455 | |
|
|
456 | signal (SIGINT , SIG_IGN); |
454 | signal (SIGINT , SIG_IGN); |
457 | signal (SIGTERM, SIG_IGN); |
455 | signal (SIGTERM, SIG_IGN); |
458 | signal (SIGABRT, SIG_IGN); |
456 | signal (SIGABRT, SIG_IGN); |
459 | |
457 | |
460 | signal (SIGSEGV, SIG_DFL); |
458 | signal (SIGSEGV, SIG_DFL); |